Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
improve performance when quickly switching notes (by e.g. holding down arrow in the tree)
azivner63edde8a7377
diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.jsindex c17223b691..2f568e6c29 100644--- a/src/public/javascripts/services/note_detail.js+++ b/src/public/javascripts/services/note_detail.js@@ -164,7 +164,19 @@ async function handleProtectedSession() {}async function loadNoteDetail(noteId) {- currentNote = await loadNote(noteId);+ const loadedNote = await loadNote(noteId);++ // we will try to render the new note only if it's still the active one in the tree+ // this is useful when user quickly switches notes (by e.g. holding down arrow) so that we don't+ // try to render all those loaded notes one after each other. This only guarantees that correct note+ // will be displayed independent of timing+ const currentTreeNode = treeService.getCurrentNode();+ if (currentTreeNode && currentTreeNode.data.noteId !== loadedNote.noteId) {+ return;+ }++ currentNote = loadedNote;+refreshAttributes(); // needs to happend after loading the note itself because it references current noteIdif (isNewNoteCreated) {diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.jsindex fe00f6d5bc..3fd9be332b 100644--- a/src/public/javascripts/services/tree.js+++ b/src/public/javascripts/services/tree.js@@ -332,13 +332,14 @@ function initFancyTree(tree) {}},activate: (event, data) => {- const node = data.node.data;+ const node = data.node;+ const noteId = node.data.noteId;- setCurrentNotePathToHash(data.node);+ setCurrentNotePathToHash(node);- noteDetailService.switchToNote(node.noteId);+ noteDetailService.switchToNote(noteId);- showPaths(node.noteId, data.node);+ showPaths(noteId, node);},expand: (event, data) => setExpandedToServer(data.node.data.branchId, true),collapse: (event, data) => setExpandedToServer(data.node.data.branchId, false),