From c4acecd510679e91693fab0f2a2f89f556e67803 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 23 Oct 2020 23:19:29 +0200 Subject: [PATCH] fix loading unnecessary notes into the cache --- src/routes/api/tree.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js index 57e1ad915..c27ff26e5 100644 --- a/src/routes/api/tree.js +++ b/src/routes/api/tree.js @@ -56,12 +56,12 @@ function getTree(req) { const noteIds = sql.getColumn(` WITH RECURSIVE - treeWithDescendants(noteId, isExpanded) AS ( - SELECT noteId, 1 FROM branches WHERE parentNoteId = ? AND isDeleted = 0 + treeWithDescendants(noteId) AS ( + SELECT noteId FROM branches WHERE parentNoteId = ? AND isDeleted = 0 UNION - SELECT branches.noteId, branches.isExpanded FROM branches + SELECT branches.noteId FROM branches JOIN treeWithDescendants ON branches.parentNoteId = treeWithDescendants.noteId - WHERE treeWithDescendants.isExpanded = 1 + WHERE branches.isExpanded = 1 AND branches.isDeleted = 0 ), treeWithDescendantsAndAscendants AS (