basic lazy loading of tree now works, still WIP

This commit is contained in:
azivner
2018-04-16 20:40:18 -04:00
parent 1687ed7e0b
commit 82de1c88d4
6 changed files with 154 additions and 75 deletions

View File

@@ -16,13 +16,18 @@ class NoteShort {
async getBranches() {
const branches = [];
for (const parent of this.treeCache.parents[this.noteId]) {
branches.push(await this.treeCache.getBranchByChildParent(this.noteId, parent.noteId));
for (const parentNoteId of this.treeCache.parents[this.noteId]) {
branches.push(await this.treeCache.getBranchByChildParent(this.noteId, parentNoteId));
}
return branches;
}
hasChildren() {
return this.treeCache.children[this.noteId]
&& this.treeCache.children[this.noteId].length > 0;
}
async getChildBranches() {
if (!this.treeCache.children[this.noteId]) {
return [];
@@ -30,19 +35,33 @@ class NoteShort {
const branches = [];
for (const child of this.treeCache.children[this.noteId]) {
branches.push(await this.treeCache.getBranchByChildParent(child.noteId, this.noteId));
for (const childNoteId of this.treeCache.children[this.noteId]) {
branches.push(await this.treeCache.getBranchByChildParent(childNoteId, this.noteId));
}
return branches;
}
async __getNotes(noteIds) {
if (!noteIds) {
return [];
}
const notes = [];
for (const noteId of noteIds) {
notes.push(await this.treeCache.getNote(noteId));
}
return notes;
}
async getParentNotes() {
return this.treeCache.parents[this.noteId] || [];
return this.__getNotes(this.treeCache.parents[this.noteId]);
}
async getChildNotes() {
return this.treeCache.children[this.noteId] || [];
return this.__getNotes(this.treeCache.children[this.noteId]);
}
get toString() {