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
fix tree loading (partial revert of previous commit)
zadam6517188b39bb
diff --git a/src/routes/api/tree.js b/src/routes/api/tree.jsindex c27ff26e59..eca5313e01 100644--- a/src/routes/api/tree.js+++ b/src/routes/api/tree.js@@ -54,14 +54,15 @@ function getNotesAndBranchesAndAttributes(noteIds) {function getTree(req) {const subTreeNoteId = req.query.subTreeNoteId || optionService.getOption('hoistedNoteId');+ // FIXME: this query does not return ascendants of template notesconst noteIds = sql.getColumn(`WITH RECURSIVE- treeWithDescendants(noteId) AS (- SELECT noteId FROM branches WHERE parentNoteId = ? AND isDeleted = 0+ treeWithDescendants(noteId, isExpanded) AS (+ SELECT noteId, isExpanded FROM branches WHERE parentNoteId = ? AND isDeleted = 0UNION- SELECT branches.noteId FROM branches+ SELECT branches.noteId, branches.isExpanded FROM branchesJOIN treeWithDescendants ON branches.parentNoteId = treeWithDescendants.noteId- WHERE branches.isExpanded = 1+ WHERE treeWithDescendants.isExpanded = 1AND branches.isDeleted = 0),treeWithDescendantsAndAscendants AS (@@ -83,7 +84,7 @@ function getTree(req) {)SELECT noteId FROM treeWithDescendantsAscendantsAndTemplates`, [subTreeNoteId, subTreeNoteId]);- noteIds.push(subTreeNoteId);+ noteIds.push(subTreeNoteId);console.log("noteIds", noteIds);return getNotesAndBranchesAndAttributes(noteIds);}