lazy loading of note complement

This commit is contained in:
zadam
2020-02-01 11:33:31 +01:00
parent f6f7836b8e
commit f0cbca2838
11 changed files with 61 additions and 29 deletions

View File

@@ -51,9 +51,6 @@ class TabContext extends Component {
/** @property {NoteShort} */
this.note = await treeCache.getNote(noteId);
/** @property {NoteComplement} */
this.noteComplement = await noteDetailService.loadNoteComplement(noteId);
//this.cleanup(); // esp. on windows autocomplete is not getting closed automatically
setTimeout(async () => {
@@ -78,6 +75,23 @@ class TabContext extends Component {
this.trigger('openTabsChanged');
}
get noteId() {
return this.note && this.note.noteId;
}
/** @return {NoteComplement} */
async getNoteComplement() {
if (!this.noteId) {
return null;
}
if (!this.noteComplementPromise) {
this.noteComplementPromise = noteDetailService.loadNoteComplement(this.noteId);
}
return await this.noteComplementPromise;
}
async remove() {
await this.trigger('beforeTabRemove', {tabId: this.tabId}, true);