option to erase notes immediately

This commit is contained in:
zadam
2021-09-16 14:38:09 +02:00
parent 9b9be5d155
commit 0448883782
10 changed files with 74 additions and 16 deletions

View File

@@ -205,12 +205,17 @@ function setExpandedForSubtree(req) {
function deleteBranch(req) {
const last = req.query.last === 'true';
const eraseNotes = req.query.eraseNotes === 'true';
const branch = becca.getBranch(req.params.branchId);
const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes');
const deleteId = utils.randomString(10);
const noteDeleted = noteService.deleteBranch(branch, deleteId, taskContext);
if (eraseNotes) {
noteService.eraseNotesWithDeleteId(deleteId);
}
if (last) {
taskContext.taskSucceeded();
}

View File

@@ -121,6 +121,22 @@ function getSearchRoot() {
return searchRoot;
}
function getSpecialNoteRoot() {
let specialNoteRoot = becca.getNote('special');
if (!specialNoteRoot) {
specialNoteRoot = noteService.createNewNote({
noteId: 'special',
title: 'special',
type: 'text',
content: '',
parentNoteId: getHiddenRoot().noteId
}).note;
}
return specialNoteRoot;
}
function getSqlConsoleRoot() {
let sqlConsoleRoot = becca.getNote('sqlconsole');

View File

@@ -63,6 +63,7 @@ function updateNote(req) {
function deleteNote(req) {
const noteId = req.params.noteId;
const taskId = req.query.taskId;
const eraseNotes = req.query.eraseNotes === 'true';
const last = req.query.last === 'true';
// note how deleteId is separate from taskId - single taskId produces separate deleteId for each "top level" deleted note
@@ -76,6 +77,10 @@ function deleteNote(req) {
noteService.deleteBranch(branch, deleteId, taskContext);
}
if (eraseNotes) {
noteService.eraseNotesWithDeleteId(deleteId);
}
if (last) {
taskContext.taskSucceeded();
}