mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	fix "no data" when switching between tabs with different hoisted notes, closes #1699
This commit is contained in:
		| @@ -15,7 +15,7 @@ export default class SpacedUpdate { | |||||||
|  |  | ||||||
|     async updateNowIfNecessary() { |     async updateNowIfNecessary() { | ||||||
|         if (this.changed) { |         if (this.changed) { | ||||||
|             this.changed = false; // optimistic...k |             this.changed = false; // optimistic... | ||||||
|  |  | ||||||
|             try { |             try { | ||||||
|                 await this.updater(); |                 await this.updater(); | ||||||
|   | |||||||
| @@ -804,12 +804,11 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|     /** @return {FancytreeNode} */ |     /** @return {FancytreeNode} */ | ||||||
|     async getNodeFromPath(notePath, expand = false, logErrors = true) { |     async getNodeFromPath(notePath, expand = false, logErrors = true) { | ||||||
|         utils.assertArguments(notePath); |         utils.assertArguments(notePath); | ||||||
|  |         /** @let {FancytreeNode} */ | ||||||
|  |         let parentNode = this.getNodesByNoteId('root')[0]; | ||||||
|  |  | ||||||
|         const hoistedNoteId = hoistedNoteService.getHoistedNoteId(); |         const resolvedNotePathSegments = (await treeService.resolveNotePathToSegments(notePath, logErrors)) | ||||||
|         /** @const {FancytreeNode} */ |             .slice(1); | ||||||
|         let parentNode = null; |  | ||||||
|  |  | ||||||
|         const resolvedNotePathSegments = await treeService.resolveNotePathToSegments(notePath, logErrors); |  | ||||||
|  |  | ||||||
|         if (!resolvedNotePathSegments) { |         if (!resolvedNotePathSegments) { | ||||||
|             if (logErrors) { |             if (logErrors) { | ||||||
| @@ -820,13 +819,6 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         for (const childNoteId of resolvedNotePathSegments) { |         for (const childNoteId of resolvedNotePathSegments) { | ||||||
|             if (childNoteId === hoistedNoteId) { |  | ||||||
|                 // there must be exactly one node with given hoistedNoteId |  | ||||||
|                 parentNode = this.getNodesByNoteId(childNoteId)[0]; |  | ||||||
|  |  | ||||||
|                 continue; |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             // we expand only after hoisted note since before then nodes are not actually present in the tree |             // we expand only after hoisted note since before then nodes are not actually present in the tree | ||||||
|             if (parentNode) { |             if (parentNode) { | ||||||
|                 if (!parentNode.isLoaded()) { |                 if (!parentNode.isLoaded()) { | ||||||
| @@ -857,7 +849,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|                             // these are real notes with real notePath, user can display them in a detail |                             // these are real notes with real notePath, user can display them in a detail | ||||||
|                             // but they don't have a node in the tree |                             // but they don't have a node in the tree | ||||||
|  |  | ||||||
|                             ws.logError(`Can't find node for child node of noteId=${childNoteId} for parent of noteId=${parentNode.data.noteId} and hoistedNoteId=${hoistedNoteId}, requested path is ${notePath}`); |                             ws.logError(`Can't find node for child node of noteId=${childNoteId} for parent of noteId=${parentNode.data.noteId} and hoistedNoteId=${hoistedNoteService.getHoistedNoteId()}, requested path is ${notePath}`); | ||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                         return; |                         return; | ||||||
| @@ -1207,8 +1199,12 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     filterHoistedBranch() { |     async filterHoistedBranch() { | ||||||
|         if (this.tabContext) { |         if (this.tabContext) { | ||||||
|  |             // make sure the hoisted node is loaded (can be unloaded e.g. after tree collapse in another tab) | ||||||
|  |             const hoistedNotePath = await treeService.resolveNotePath(this.tabContext.hoistedNoteId); | ||||||
|  |             await this.getNodeFromPath(hoistedNotePath); | ||||||
|  |  | ||||||
|             if (this.tabContext.hoistedNoteId === 'root') { |             if (this.tabContext.hoistedNoteId === 'root') { | ||||||
|                 this.tree.clearFilter(); |                 this.tree.clearFilter(); | ||||||
|             } |             } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user