mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08:00 
			
		
		
		
	fix finding single note by label with mixed case
This commit is contained in:
		
							parent
							
								
									a08690b123
								
							
						
					
					
						commit
						20696aa0ab
					
				| @ -29,7 +29,13 @@ class Becca { | |||||||
| 
 | 
 | ||||||
|     /** @return {Attribute[]} */ |     /** @return {Attribute[]} */ | ||||||
|     findAttributes(type, name) { |     findAttributes(type, name) { | ||||||
|         return this.attributeIndex[`${type}-${name.toLowerCase()}`] || []; |         name = name.trim().toLowerCase(); | ||||||
|  | 
 | ||||||
|  |         if (name.startsWith('#') || name.startsWith('~')) { | ||||||
|  |             name = name.substr(1); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return this.attributeIndex[`${type}-${name}`] || []; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** @return {Attribute[]} */ |     /** @return {Attribute[]} */ | ||||||
|  | |||||||
| @ -33,7 +33,8 @@ export default class EditedNotesWidget extends CollapsibleWidget { | |||||||
|     getTitle() { |     getTitle() { | ||||||
|         return { |         return { | ||||||
|             show: this.isEnabled(), |             show: this.isEnabled(), | ||||||
|             activate: true, |             // promoted attributes have priority over edited notes
 | ||||||
|  |             activate: this.note.getPromotedDefinitionAttributes().length === 0, | ||||||
|             title: 'Edited Notes', |             title: 'Edited Notes', | ||||||
|             icon: 'bx bx-calendar-edit' |             icon: 'bx bx-calendar-edit' | ||||||
|         }; |         }; | ||||||
|  | |||||||
| @ -75,8 +75,14 @@ function getNoteWithLabel(name, value) { | |||||||
|     // optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes
 |     // optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes
 | ||||||
|     const attrs = becca.findAttributes('label', name); |     const attrs = becca.findAttributes('label', name); | ||||||
| 
 | 
 | ||||||
|  |     if (value === undefined) { | ||||||
|  |         return attrs[0]?.getNote(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     value = value?.toLowerCase(); | ||||||
|  | 
 | ||||||
|     for (const attr of attrs) { |     for (const attr of attrs) { | ||||||
|         if (attr.value === value) { |         if (attr.value.toLowerCase() === value) { | ||||||
|             return attr.getNote(); |             return attr.getNote(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -36,7 +36,6 @@ function getNoteStartingWith(parentNoteId, startsWith) { | |||||||
| 
 | 
 | ||||||
| /** @return {Note} */ | /** @return {Note} */ | ||||||
| function getRootCalendarNote() { | function getRootCalendarNote() { | ||||||
|     // some caching here could be useful (e.g. in CLS)
 |  | ||||||
|     let rootNote = attributeService.getNoteWithLabel(CALENDAR_ROOT_LABEL); |     let rootNote = attributeService.getNoteWithLabel(CALENDAR_ROOT_LABEL); | ||||||
| 
 | 
 | ||||||
|     if (!rootNote) { |     if (!rootNote) { | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ class LabelComparisonExp extends Expression { | |||||||
| 
 | 
 | ||||||
|         for (const attr of attrs) { |         for (const attr of attrs) { | ||||||
|             const note = attr.note; |             const note = attr.note; | ||||||
|             const value = attr.value ? attr.value.toLowerCase() : attr.value; |             const value = attr.value?.toLowerCase(); | ||||||
| 
 | 
 | ||||||
|             if (inputNoteSet.hasNoteId(note.noteId) && this.comparator(value)) { |             if (inputNoteSet.hasNoteId(note.noteId) && this.comparator(value)) { | ||||||
|                 if (attr.isInheritable) { |                 if (attr.isInheritable) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam