mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
no need to reload whole subtree while moving notes
This commit is contained in:
parent
e817acba4e
commit
ad48b59893
@ -970,7 +970,9 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
const found = (parentNode.getChildren() || []).find(child => child.data.noteId === branch.noteId);
|
const found = (parentNode.getChildren() || []).find(child => child.data.noteId === branch.noteId);
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
noteIdsToReload.add(branch.parentNoteId);
|
parentNode.addChildren([await this.prepareNode(branch)]);
|
||||||
|
|
||||||
|
this.sortChildren(parentNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -992,16 +994,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
for (const parentNoteId of loadResults.getNoteReorderings()) {
|
for (const parentNoteId of loadResults.getNoteReorderings()) {
|
||||||
for (const node of this.getNodesByNoteId(parentNoteId)) {
|
for (const node of this.getNodesByNoteId(parentNoteId)) {
|
||||||
if (node.isLoaded()) {
|
if (node.isLoaded()) {
|
||||||
node.sortChildren((nodeA, nodeB) => {
|
this.sortChildren(node);
|
||||||
const branchA = treeCache.branches[nodeA.data.branchId];
|
|
||||||
const branchB = treeCache.branches[nodeB.data.branchId];
|
|
||||||
|
|
||||||
if (!branchA || !branchB) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return branchA.notePosition - branchB.notePosition;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1047,6 +1040,19 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortChildren(node) {
|
||||||
|
node.sortChildren((nodeA, nodeB) => {
|
||||||
|
const branchA = treeCache.branches[nodeA.data.branchId];
|
||||||
|
const branchB = treeCache.branches[nodeB.data.branchId];
|
||||||
|
|
||||||
|
if (!branchA || !branchB) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return branchA.notePosition - branchB.notePosition;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async setExpanded(branchId, isExpanded) {
|
async setExpanded(branchId, isExpanded) {
|
||||||
utils.assertArguments(branchId);
|
utils.assertArguments(branchId);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user