From 4f75b6aaafef8144080fd17f403a605f61f5590d Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 29 Oct 2020 22:41:33 +0100 Subject: [PATCH] fix removing stale branches from saved search after refresh, fixes #1354 --- src/public/app/services/toast.js | 2 +- src/public/app/services/tree_cache.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/public/app/services/toast.js b/src/public/app/services/toast.js index 02e2595ca..d51cad528 100644 --- a/src/public/app/services/toast.js +++ b/src/public/app/services/toast.js @@ -54,7 +54,7 @@ function closePersistent(id) { } function showMessage(message, delay = 2000) { - console.debug(utils.now(), "message: ", message); + console.debug(utils.now(), "message:", message); toast({ title: "Info", diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js index f8fe862ac..e3649d18f 100644 --- a/src/public/app/services/tree_cache.js +++ b/src/public/app/services/tree_cache.js @@ -203,6 +203,11 @@ class TreeCache { // force to load all the notes at once instead of one by one await this.getNotes(searchResultNoteIds); + // reset all the virtual branches from old search results + if (note.noteId in treeCache.notes) { + treeCache.notes[note.noteId].children = []; + } + const branches = resp.branches.filter(b => b.noteId === note.noteId || b.parentNoteId === note.noteId); searchResultNoteIds.forEach((resultNoteId, index) => branches.push({