delete/undelete fixes

This commit is contained in:
zadam 2020-01-03 13:41:44 +01:00
parent 14f3c783f2
commit 17b23d92ef
2 changed files with 7 additions and 6 deletions

View File

@ -418,14 +418,16 @@ async function deleteBranch(branch, deleteId, taskContext) {
const notDeletedBranches = await note.getBranches();
if (notDeletedBranches.length === 0) {
note.isDeleted = true;
note.deleteId = deleteId;
await note.save();
for (const childBranch of await note.getChildBranches()) {
await deleteBranch(childBranch, deleteId, taskContext);
}
// first delete children and then parent - this will show up better in recent changes
note.isDeleted = true;
note.deleteId = deleteId;
await note.save();
for (const attribute of await note.getOwnedAttributes()) {
attribute.isDeleted = true;
attribute.deleteId = deleteId;
@ -508,7 +510,7 @@ async function undeleteBranch(branch, deleteId, taskContext) {
AND branches.parentNoteId = ?`, [deleteId, note.noteId]);
for (const childBranch of childBranches) {
await deleteBranch(childBranch, deleteId, taskContext);
await undeleteBranch(childBranch, deleteId, taskContext);
}
}
}

View File

@ -2,7 +2,6 @@ const sql = require('./sql');
const ScriptContext = require('./script_context');
const repository = require('./repository');
const cls = require('./cls');
const sourceIdService = require('./source_id');
const log = require('./log');
async function executeNote(note, apiParams) {