Skip to content

Build your personal knowledge base with Trilium Notes

initial load of tabs can run partially asynchronously to speed things up

zadamaa96b33bc226
diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js
index cf2831d5c6..708b49c7ec 100644
--- a/src/public/javascripts/services/note_detail.js
+++ b/src/public/javascripts/services/note_detail.js
@@ -275,12 +275,19 @@ async function loadNoteDetail(origNotePath, options = {}) {
if (!newTab && currentTreeNode && currentTreeNode.data.noteId !== loadedNote.noteId) {
return;
}
+
+ const loadPromise = loadNoteDetailToContext(ctx, loadedNote, notePath).then(() => {
+ if (activate) {
+ // will also trigger showTab via event
+ return tabRow.activateTab(ctx.$tab[0]);
+ }
+ else {
+ return Promise.resolve();
+ }
+ });
- await loadNoteDetailToContext(ctx, loadedNote, notePath);
-
- if (activate) {
- // will also trigger showTab via event
- await tabRow.activateTab(ctx.$tab[0]);
+ if (!options.async) {
+ await loadPromise;
}
}
diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js
index 5ffd5241d8..79078152da 100644
--- a/src/public/javascripts/services/tree.js
+++ b/src/public/javascripts/services/tree.js
@@ -391,7 +391,8 @@ async function treeInitialized() {
await noteDetailService.loadNoteDetail(tab.notePath, {
state: tab,
newTab: true,
- activate: tab.active
+ activate: tab.active,
+ async: true // faster initial load
});
}