mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	fix activating note by noteId when hoisting, fixes #320
This commit is contained in:
		
							parent
							
								
									0722494d41
								
							
						
					
					
						commit
						48bbfb8bdb
					
				| @ -94,9 +94,18 @@ async function expandToNote(notePath, expandOpts) { | ||||
| 
 | ||||
|     const noteId = treeUtils.getNoteIdFromNotePath(notePath); | ||||
| 
 | ||||
|     const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); | ||||
|     let hoistedNoteFound = false; | ||||
| 
 | ||||
|     let parentNoteId = null; | ||||
| 
 | ||||
|     for (const childNoteId of runPath) { | ||||
|         if (childNoteId === hoistedNoteId) { | ||||
|             hoistedNoteFound = true; | ||||
|         } | ||||
| 
 | ||||
|         // we expand only after hoisted note since before then nodes are not actually present in the tree
 | ||||
|         if (hoistedNoteFound) { | ||||
|             // for first node (!parentNoteId) it doesn't matter which node is found
 | ||||
|             let node = getNode(childNoteId, parentNoteId); | ||||
| 
 | ||||
| @ -117,10 +126,10 @@ async function expandToNote(notePath, expandOpts) { | ||||
| 
 | ||||
|             if (childNoteId === noteId) { | ||||
|                 return node; | ||||
|         } | ||||
|         else { | ||||
|             } else { | ||||
|                 await node.setExpanded(true, expandOpts); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         parentNoteId = childNoteId; | ||||
|     } | ||||
| @ -129,9 +138,12 @@ async function expandToNote(notePath, expandOpts) { | ||||
| async function activateNote(notePath, noteLoadedListener) { | ||||
|     utils.assertArguments(notePath); | ||||
| 
 | ||||
|     // notePath argument can contain only noteId which is not good when hoisted since
 | ||||
|     // then we need to check the whole note path
 | ||||
|     const runNotePath = await getRunPath(notePath); | ||||
|     const hoistedNoteId = await hoistedNoteService.getHoistedNoteId(); | ||||
| 
 | ||||
|     if (hoistedNoteId !== 'root' && !notePath.includes(hoistedNoteId)) { | ||||
|     if (hoistedNoteId !== 'root' && !runNotePath.includes(hoistedNoteId)) { | ||||
|         if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree. Do you want to unhoist?")) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner