This commit is contained in:
zadam 2019-10-26 20:48:56 +02:00
parent 7ccbf45569
commit bdf42749f3
3 changed files with 9 additions and 6 deletions

View file

@ -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);

View file

@ -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();
}

View file

@ -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];
}
}
}