initializing note tree synchronously

This commit is contained in:
zadam
2020-08-26 16:50:16 +02:00
parent 87161cfe0d
commit 6aa61ca306
6 changed files with 87 additions and 76 deletions

View File

@@ -20,8 +20,6 @@ class TreeCache {
async loadInitialTree() {
const resp = await server.get('tree');
await this.loadParents(resp, false);
// clear the cache only directly before adding new content which is important for e.g. switching to protected session
/** @type {Object.<string, NoteShort>} */
@@ -39,6 +37,14 @@ class TreeCache {
this.addResp(resp);
}
async loadSubTree(subTreeNoteId) {
const resp = await server.get('tree?subTreeNoteId=' + subTreeNoteId);
this.addResp(resp);
return this.notes[subTreeNoteId];
}
async loadParents(resp, additiveLoad) {
const noteIds = new Set(resp.notes.map(note => note.noteId));
const missingNoteIds = [];