mirror of
https://github.com/zadam/trilium.git
synced 2025-02-22 14:03:36 +08:00
make node activation after load clearer
This commit is contained in:
parent
d48efd1925
commit
15f4782947
1 changed files with 5 additions and 15 deletions
|
@ -403,27 +403,20 @@ function initFancyTree(tree) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeActivate: (event, data) => {
|
beforeActivate: (event, data) => {
|
||||||
// this is for the case when tree reload has been called and we don't want to
|
// make sure the reload won't trigger reactivation.
|
||||||
// FIXME: why do we have this in both beforeActivate and activate?
|
// This is important especially in cases where we wait for the reload to finish to then activate some other note.
|
||||||
// FIXME: also shouldn't we set ignoreNextActivationNoteId in any case? Otherwise subsequent activation of this note might be one-time ignored
|
// But since the activate() event is called asynchronously, it may be called (or finished calling)
|
||||||
|
// after we switched to a different note so it's not possible to just check if current note matches requested note
|
||||||
if (ignoreNextActivationNoteId && getActiveNode() !== null && getActiveNode().data.noteId === data.node.data.noteId) {
|
if (ignoreNextActivationNoteId && getActiveNode() !== null && getActiveNode().data.noteId === data.node.data.noteId) {
|
||||||
ignoreNextActivationNoteId = null;
|
ignoreNextActivationNoteId = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activate: async (event, data) => {
|
activate: async (event, data) => {
|
||||||
const node = data.node;
|
|
||||||
const noteId = node.data.noteId;
|
|
||||||
|
|
||||||
if (ignoreNextActivationNoteId === noteId) {
|
|
||||||
ignoreNextActivationNoteId = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// click event won't propagate so let's close context menu manually
|
// click event won't propagate so let's close context menu manually
|
||||||
contextMenuWidget.hideContextMenu();
|
contextMenuWidget.hideContextMenu();
|
||||||
|
|
||||||
const notePath = await treeUtils.getNotePath(node);
|
const notePath = await treeUtils.getNotePath(data.node);
|
||||||
|
|
||||||
noteDetailService.switchToNote(notePath);
|
noteDetailService.switchToNote(notePath);
|
||||||
},
|
},
|
||||||
|
@ -497,9 +490,6 @@ function getTree() {
|
||||||
async function reload() {
|
async function reload() {
|
||||||
const notes = await loadTree();
|
const notes = await loadTree();
|
||||||
|
|
||||||
// make sure the reload won't trigger reactivation. This is important especially in cases where we wait for the reload
|
|
||||||
// to finish to then activate some other note. But since the activate() event is called asynchronously, it may be called
|
|
||||||
// (or finished calling) after we switched to a different note.
|
|
||||||
if (getActiveNode()) {
|
if (getActiveNode()) {
|
||||||
ignoreNextActivationNoteId = getActiveNode().data.noteId;
|
ignoreNextActivationNoteId = getActiveNode().data.noteId;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue