mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	added optimized version for single label searching + noteset cache fix
This commit is contained in:
		
							parent
							
								
									7152c5e51d
								
							
						
					
					
						commit
						e10e18e63a
					
				| @ -154,10 +154,10 @@ class Becca { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             this.allNoteSet = new NoteSet(allNotes); |             this.allNoteSetCache = new NoteSet(allNotes); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return this.allNoteSet; |         return this.allNoteSetCache; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -71,9 +71,16 @@ function getNotesWithLabel(name, value) { | |||||||
| 
 | 
 | ||||||
| // TODO: should be in search service
 | // TODO: should be in search service
 | ||||||
| function getNoteWithLabel(name, value) { | function getNoteWithLabel(name, value) { | ||||||
|     const notes = getNotesWithLabel(name, value); |     // optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes
 | ||||||
|  |     const attrs = becca.findAttributes('label', name); | ||||||
| 
 | 
 | ||||||
|     return notes.length > 0 ? notes[0] : null; |     for (const attr of attrs) { | ||||||
|  |         if (attr.value === value) { | ||||||
|  |             return attr.getNote(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return null; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function createLabel(noteId, name, value = "") { | function createLabel(noteId, name, value = "") { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam