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