From 69d739400caf2637a7192a4b76dc9754514680f3 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 22 Oct 2019 22:27:32 +0200 Subject: [PATCH] refresh notes/branches sorted --- src/routes/api/tree.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js index 3f47a711c..3344babed 100644 --- a/src/routes/api/tree.js +++ b/src/routes/api/tree.js @@ -96,7 +96,11 @@ async function load(req) { .map(note => note.noteId); } - const branches = await sql.getManyRows(`SELECT * FROM branches WHERE isDeleted = 0 AND noteId IN (???)`, noteIds); + const branches = (await sql.getManyRows(`SELECT * FROM branches WHERE isDeleted = 0 AND noteId IN (???)`, noteIds)) + .concat((await sql.getManyRows(`SELECT * FROM branches WHERE isDeleted = 0 AND parentNoteId IN (???)`, noteIds))); + + // sort branches so they are filled sorted in the cache as well + branches.sort((a, b) => a.notePosition < b.notePosition ? -1 : 1); const notes = await getNotes(noteIds);