mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-29 02:28:57 +01:00 
			
		
		
		
	read filter values in icon selector only after async events, #4044
This commit is contained in:
		
							parent
							
								
									defd997424
								
							
						
					
					
						commit
						6cfd18b29b
					
				| @ -93,11 +93,11 @@ export default class NoteIconWidget extends NoteContextAwareWidget { | ||||
|         }); | ||||
| 
 | ||||
|         this.$iconCategory = this.$widget.find("select[name='icon-category']"); | ||||
|         this.$iconCategory.on('change', () => this.renderFilteredDropdown()); | ||||
|         this.$iconCategory.on('change', () => this.renderDropdown()); | ||||
|         this.$iconCategory.on('click', e => e.stopPropagation()); | ||||
| 
 | ||||
|         this.$iconSearch = this.$widget.find("input[name='icon-search']"); | ||||
|         this.$iconSearch.on('input', () => this.renderFilteredDropdown()); | ||||
|         this.$iconSearch.on('input', () => this.renderDropdown()); | ||||
| 
 | ||||
|         this.$notePathList = this.$widget.find(".note-path-list"); | ||||
|         this.$widget.on('show.bs.dropdown', async () => { | ||||
| @ -140,14 +140,7 @@ export default class NoteIconWidget extends NoteContextAwareWidget { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     renderFilteredDropdown() { | ||||
|         const categoryId = parseInt(this.$iconCategory.find('option:selected').val()); | ||||
|         const search = this.$iconSearch.val(); | ||||
| 
 | ||||
|         this.renderDropdown(categoryId, search); | ||||
|     } | ||||
| 
 | ||||
|     async renderDropdown(categoryId, search) { | ||||
|     async renderDropdown() { | ||||
|         const iconToCountPromise = this.getIconToCountMap(); | ||||
| 
 | ||||
|         this.$iconList.empty(); | ||||
| @ -165,8 +158,10 @@ export default class NoteIconWidget extends NoteContextAwareWidget { | ||||
|         } | ||||
| 
 | ||||
|         const {icons} = (await import('./icon_list.js')).default; | ||||
|         const iconToCount = await iconToCountPromise; | ||||
| 
 | ||||
|         search = search?.trim()?.toLowerCase(); | ||||
|         const categoryId = parseInt(this.$iconCategory.find('option:selected').val()); | ||||
|         const search = this.$iconSearch.val().trim().toLowerCase(); | ||||
| 
 | ||||
|         const filteredIcons = icons.filter(icon => { | ||||
|             if (categoryId && icon.category_id !== categoryId) { | ||||
| @ -182,8 +177,6 @@ export default class NoteIconWidget extends NoteContextAwareWidget { | ||||
|             return true; | ||||
|         }); | ||||
| 
 | ||||
|         const iconToCount = await iconToCountPromise; | ||||
| 
 | ||||
|         filteredIcons.sort((a, b) => { | ||||
|             const countA = iconToCount[a.className] || 0; | ||||
|             const countB = iconToCount[b.className] || 0; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam