mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	basic implementation of saved searches finished, closes #83
This commit is contained in:
		
							parent
							
								
									e5c0acbb43
								
							
						
					
					
						commit
						f1b0b3bcdb
					
				| @ -654,14 +654,28 @@ const noteTree = (function() { | ||||
|         $tree.contextmenu(contextMenu.contextMenuSettings); | ||||
|     } | ||||
| 
 | ||||
|     async function loadSearchNote(noteId) { | ||||
|         const note = await server.get('notes/' + noteId); | ||||
|     async function loadSearchNote(searchNoteId) { | ||||
|         const note = await server.get('notes/' + searchNoteId); | ||||
| 
 | ||||
|         const json = JSON.parse(note.detail.content); | ||||
| 
 | ||||
|         const noteIds = await server.get('notes?search=' + encodeURIComponent(json.searchString)); | ||||
| 
 | ||||
|         console.log("Found: ", noteIds); | ||||
|         for (const noteId of noteIds) { | ||||
|             const noteTreeId = "virt" + randomString(10); | ||||
| 
 | ||||
|             notesTreeMap[noteTreeId] = { | ||||
|                 noteTreeId: noteTreeId, | ||||
|                 noteId: noteId, | ||||
|                 parentNoteId: searchNoteId, | ||||
|                 prefix: '', | ||||
|                 virtual: true | ||||
|             }; | ||||
| 
 | ||||
|             setParentChildRelation(noteTreeId, searchNoteId, noteId); | ||||
|         } | ||||
| 
 | ||||
|         return prepareNoteTreeInner(searchNoteId); | ||||
|     } | ||||
| 
 | ||||
|     function getTree() { | ||||
|  | ||||
| @ -220,3 +220,14 @@ function toObject(array, fn) { | ||||
| 
 | ||||
|     return obj; | ||||
| } | ||||
| 
 | ||||
| function randomString(len) { | ||||
|     let text = ""; | ||||
|     const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||||
| 
 | ||||
|     for (let i = 0; i < len; i++) { | ||||
|         text += possible.charAt(Math.floor(Math.random() * possible.length)); | ||||
|     } | ||||
| 
 | ||||
|     return text; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner