mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix expanded status when moving note trees
This commit is contained in:
parent
87a60e325f
commit
ca041bb658
@ -1147,6 +1147,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
let parentsOfAddedNodes = [];
|
||||
|
||||
const allBranchRows = loadResults.getBranchRows();
|
||||
// TODO: this flag is suspicious - why does it matter that all branches in a particular update are deleted?
|
||||
const allBranchesDeleted = allBranchRows.every(branchRow => !!branchRow.isDeleted);
|
||||
|
||||
for (const branchRow of allBranchRows) {
|
||||
@ -1159,8 +1160,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
noteIdsToUpdate.add(branchRow.noteId);
|
||||
}
|
||||
|
||||
for (const node of this.getNodesByBranch(branchRow)) {
|
||||
if (branchRow.isDeleted) {
|
||||
if (branchRow.isDeleted) {
|
||||
for (const node of this.getNodesByBranch(branchRow)) {
|
||||
if (node.isActive()) {
|
||||
if (allBranchesDeleted) {
|
||||
const newActiveNode = node.getNextSibling()
|
||||
@ -1181,9 +1182,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
|
||||
noteIdsToUpdate.add(branchRow.parentNoteId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!branchRow.isDeleted) {
|
||||
} else {
|
||||
for (const parentNode of this.getNodesByNoteId(branchRow.parentNoteId)) {
|
||||
parentsOfAddedNodes.push(parentNode)
|
||||
|
||||
@ -1194,12 +1193,16 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
||||
const found = (parentNode.getChildren() || []).find(child => child.data.noteId === branchRow.noteId);
|
||||
if (!found) {
|
||||
// make sure it's loaded
|
||||
await froca.getNote(branchRow.noteId);
|
||||
const note = await froca.getNote(branchRow.noteId);
|
||||
const frocaBranch = froca.getBranch(branchRow.branchId);
|
||||
|
||||
// we're forcing lazy since it's not clear if the whole required subtree is in froca
|
||||
parentNode.addChildren([this.prepareNode(frocaBranch, true)]);
|
||||
|
||||
if (frocaBranch.isExpanded && note.hasChildren()) {
|
||||
noteIdsToReload.add(frocaBranch.noteId);
|
||||
}
|
||||
|
||||
this.sortChildren(parentNode);
|
||||
|
||||
// this might be a first child which would force an icon change
|
||||
|
Loading…
x
Reference in New Issue
Block a user