mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
better activation behavior when move notes
This commit is contained in:
parent
ca0e36ea81
commit
5024454914
@ -460,6 +460,10 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async entitiesReloadedEvent({loadResults}) {
|
async entitiesReloadedEvent({loadResults}) {
|
||||||
|
const activeNode = this.getActiveNode();
|
||||||
|
const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;
|
||||||
|
const activeNoteId = activeNode ? activeNode.data.noteId : null;
|
||||||
|
|
||||||
const noteIdsToUpdate = new Set();
|
const noteIdsToUpdate = new Set();
|
||||||
const noteIdsToReload = new Set();
|
const noteIdsToReload = new Set();
|
||||||
|
|
||||||
@ -515,9 +519,6 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeNode = this.getActiveNode();
|
|
||||||
const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;
|
|
||||||
|
|
||||||
for (const noteId of loadResults.getNoteIds()) {
|
for (const noteId of loadResults.getNoteIds()) {
|
||||||
noteIdsToUpdate.add(noteId);
|
noteIdsToUpdate.add(noteId);
|
||||||
}
|
}
|
||||||
@ -554,11 +555,22 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (activeNotePath) {
|
if (activeNotePath) {
|
||||||
const node = await this.expandToNote(activeNotePath);
|
let node = await this.expandToNote(activeNotePath);
|
||||||
|
|
||||||
|
if (node.data.noteId !== activeNoteId) {
|
||||||
|
// if the active note has been moved elsewhere then it won't be found by the path
|
||||||
|
// so we switch to the alternative of trying to find it by noteId
|
||||||
|
const notesById = this.getNodesByNoteId(activeNoteId);
|
||||||
|
|
||||||
|
// if there are multiple clones then we'd rather not activate any one
|
||||||
|
node = notesById.length === 1 ? notesById[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node) {
|
||||||
node.setActive(true, {noEvents: true});
|
node.setActive(true, {noEvents: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async setExpandedToServer(branchId, isExpanded) {
|
async setExpandedToServer(branchId, isExpanded) {
|
||||||
utils.assertArguments(branchId);
|
utils.assertArguments(branchId);
|
||||||
|
@ -32,6 +32,7 @@ async function moveBranchToParent(req) {
|
|||||||
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 10;
|
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 10;
|
||||||
|
|
||||||
const newBranch = branchToMove.createClone(parentNoteId, newNotePos);
|
const newBranch = branchToMove.createClone(parentNoteId, newNotePos);
|
||||||
|
newBranch.isExpanded = true;
|
||||||
await newBranch.save();
|
await newBranch.save();
|
||||||
|
|
||||||
branchToMove.isDeleted = true;
|
branchToMove.isDeleted = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user