Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
delete/undelete fixes
zadam17b23d92efd7
diff --git a/src/services/notes.js b/src/services/notes.jsindex 8bd488450f..123b9df9ce 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -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);}}}diff --git a/src/services/script.js b/src/services/script.jsindex 153d535aaf..51b456eb93 100644--- a/src/services/script.js+++ b/src/services/script.js@@ -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) {