mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +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() { | ||||
|         if (this.changed) { | ||||
|             this.changed = false; // optimistic...k | ||||
|             this.changed = false; // optimistic... | ||||
|  | ||||
|             try { | ||||
|                 await this.updater(); | ||||
|   | ||||
| @@ -804,12 +804,11 @@ export default class NoteTreeWidget extends TabAwareWidget { | ||||
|     /** @return {FancytreeNode} */ | ||||
|     async getNodeFromPath(notePath, expand = false, logErrors = true) { | ||||
|         utils.assertArguments(notePath); | ||||
|         /** @let {FancytreeNode} */ | ||||
|         let parentNode = this.getNodesByNoteId('root')[0]; | ||||
|  | ||||
|         const hoistedNoteId = hoistedNoteService.getHoistedNoteId(); | ||||
|         /** @const {FancytreeNode} */ | ||||
|         let parentNode = null; | ||||
|  | ||||
|         const resolvedNotePathSegments = await treeService.resolveNotePathToSegments(notePath, logErrors); | ||||
|         const resolvedNotePathSegments = (await treeService.resolveNotePathToSegments(notePath, logErrors)) | ||||
|             .slice(1); | ||||
|  | ||||
|         if (!resolvedNotePathSegments) { | ||||
|             if (logErrors) { | ||||
| @@ -820,13 +819,6 @@ export default class NoteTreeWidget extends TabAwareWidget { | ||||
|         } | ||||
|  | ||||
|         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 | ||||
|             if (parentNode) { | ||||
|                 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 | ||||
|                             // 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; | ||||
| @@ -1207,8 +1199,12 @@ export default class NoteTreeWidget extends TabAwareWidget { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     filterHoistedBranch() { | ||||
|     async filterHoistedBranch() { | ||||
|         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') { | ||||
|                 this.tree.clearFilter(); | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user