From bdf42749f34554646627a538e4829adbd7839c13 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 26 Oct 2019 20:48:56 +0200 Subject: [PATCH] fixes --- src/public/javascripts/entities/note_short.js | 2 +- src/public/javascripts/services/tree.js | 1 + src/public/javascripts/services/tree_cache.js | 12 +++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/public/javascripts/entities/note_short.js b/src/public/javascripts/entities/note_short.js index ccae6c0fb..aa5035797 100644 --- a/src/public/javascripts/entities/note_short.js +++ b/src/public/javascripts/entities/note_short.js @@ -80,7 +80,7 @@ class NoteShort { const branchIdPos = {}; for (const branchId of Object.values(this.childToBranch)) { - branchIdPos[branchId] = this.treeCache.branches[branchId].notePosition; + branchIdPos[branchId] = this.treeCache.getBranch(branchId).notePosition; } this.children.sort((a, b) => branchIdPos[this.childToBranch[a]] < branchIdPos[this.childToBranch[b]] ? -1 : 1); diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 202d248f6..545d5f942 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -824,6 +824,7 @@ async function checkFolderStatus(node) { node.folder = note.type === 'search' || note.getChildNoteIds().length > 0; node.icon = await treeBuilder.getIcon(note); + node.extraClasses = await treeBuilder.getExtraClasses(note); node.renderTitle(); } diff --git a/src/public/javascripts/services/tree_cache.js b/src/public/javascripts/services/tree_cache.js index ed905fd9a..3a672f78a 100644 --- a/src/public/javascripts/services/tree_cache.js +++ b/src/public/javascripts/services/tree_cache.js @@ -31,8 +31,6 @@ class TreeCache { for (const branchRow of branchRows) { const branch = new Branch(this, branchRow); - this.addBranch(branch); - branchesByNotes[branch.noteId] = branchesByNotes[branch.noteId] || []; branchesByNotes[branch.noteId].push(branch); @@ -79,6 +77,10 @@ class TreeCache { } } + for (const branch of branchesByNotes[noteId]) { + this.addBranch(branch); + } + const note = new NoteShort(this, noteRow, branchesByNotes[noteId]); this.notes[note.noteId] = note; @@ -102,7 +104,6 @@ class TreeCache { } async reloadNotes(noteIds) { - // first load the data before clearing the cache const resp = await server.post('tree/load', { noteIds }); this.addResp(resp.notes, resp.branches); @@ -161,8 +162,9 @@ class TreeCache { if (!(branchId in this.branches)) { console.error(`Not existing branch ${branchId}`); } - - return this.branches[branchId]; + else { + return this.branches[branchId]; + } } }