mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
improve performance when quickly switching notes (by e.g. holding down arrow in the tree)
This commit is contained in:
parent
5872146172
commit
63edde8a73
@ -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 noteId
|
||||
|
||||
if (isNewNoteCreated) {
|
||||
|
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user