Skip to content

Build your personal knowledge base with Trilium Notes

fix(collapse-subtree): improve performance of collapsing subtrees from O(n) to O(v)

Jakob Schlanstedt1fc38e941ebf
diff --git a/apps/server/src/routes/api/branches.ts b/apps/server/src/routes/api/branches.ts
index bed1c93b7a..4cd570fcb0 100644
--- a/apps/server/src/routes/api/branches.ts
+++ b/apps/server/src/routes/api/branches.ts
@@ -163,6 +163,7 @@ function setExpandedForSubtree(req: Request) {
SELECT branches.branchId, branches.noteId FROM branches
JOIN tree ON branches.parentNoteId = tree.noteId
WHERE branches.isDeleted = 0
+ AND branches.isExpanded = 1
)
SELECT branchId FROM tree`,
[branchId]