mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
tree reload doesn't necessarily re-activates the note
This commit is contained in:
parent
225e893461
commit
f0e22b70f6
@ -114,7 +114,7 @@ async function expandToNote(notePath, expandOpts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
console.error(`Can't find node for noteId=${childNoteId} with parentNoteId=${parentNoteId}`);
|
console.error(`Can't find node for noteId=${childNoteId} with parentNoteId=${parentNoteId} and hoistedNoteId=${hoistedNoteId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (childNoteId === noteId) {
|
if (childNoteId === noteId) {
|
||||||
@ -382,6 +382,8 @@ async function treeInitialized() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let ignoreNextActivationNoteId = null;
|
||||||
|
|
||||||
function initFancyTree(tree) {
|
function initFancyTree(tree) {
|
||||||
utils.assertArguments(tree);
|
utils.assertArguments(tree);
|
||||||
|
|
||||||
@ -410,10 +412,21 @@ function initFancyTree(tree) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeActivate: (event, data) => {
|
||||||
|
// this is for the case when tree reload has been called and we don't want to
|
||||||
|
if (ignoreNextActivationNoteId && getActiveNode() !== null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
activate: async (event, data) => {
|
activate: async (event, data) => {
|
||||||
const node = data.node;
|
const node = data.node;
|
||||||
const noteId = node.data.noteId;
|
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();
|
||||||
|
|
||||||
@ -487,7 +500,11 @@ function getTree() {
|
|||||||
async function reload() {
|
async function reload() {
|
||||||
const notes = await loadTree();
|
const notes = await loadTree();
|
||||||
|
|
||||||
// this will also reload the note content
|
// 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.
|
||||||
|
ignoreNextActivationNoteId = getActiveNode().data.noteId;
|
||||||
|
|
||||||
await getTree().reload(notes);
|
await getTree().reload(notes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user