fixed search notes with new treecache

This commit is contained in:
zadam
2019-10-27 19:17:32 +01:00
parent 86a330c8c3
commit e04845335b
3 changed files with 27 additions and 29 deletions

View File

@@ -115,21 +115,22 @@ async function prepareSearchBranch(note) {
// force to load all the notes at once instead of one by one
await treeCache.getNotes(results.map(res => res.noteId));
for (const result of results) {
const origBranch = treeCache.getBranch(result.branchId);
const {notes, branches} = await server.post('tree/load', { noteIds: [note.noteId] });
const branch = new Branch(treeCache, {
branchId: "virt" + utils.randomString(10),
noteId: result.noteId,
parentNoteId: note.noteId,
prefix: origBranch.prefix,
virtual: true
});
results.forEach((result, index) => branches.push({
branchId: "virt" + utils.randomString(10),
noteId: result.noteId,
parentNoteId: note.noteId,
prefix: treeCache.getBranch(result.branchId).prefix,
notePosition: (index + 1) * 10
}));
treeCache.addBranch(branch);
}
treeCache.addResp(notes, branches);
return await prepareRealBranch(note);
// note in cache changed
const newNote = await treeCache.getNote(note.noteId);
return await prepareRealBranch(newNote);
}
async function getExtraClasses(note) {