mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 11:39:01 +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 = 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.$iconCategory.on('click', e => e.stopPropagation()); | ||||||
| 
 | 
 | ||||||
|         this.$iconSearch = this.$widget.find("input[name='icon-search']"); |         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.$notePathList = this.$widget.find(".note-path-list"); | ||||||
|         this.$widget.on('show.bs.dropdown', async () => { |         this.$widget.on('show.bs.dropdown', async () => { | ||||||
| @ -140,14 +140,7 @@ export default class NoteIconWidget extends NoteContextAwareWidget { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     renderFilteredDropdown() { |     async renderDropdown() { | ||||||
|         const categoryId = parseInt(this.$iconCategory.find('option:selected').val()); |  | ||||||
|         const search = this.$iconSearch.val(); |  | ||||||
| 
 |  | ||||||
|         this.renderDropdown(categoryId, search); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     async renderDropdown(categoryId, search) { |  | ||||||
|         const iconToCountPromise = this.getIconToCountMap(); |         const iconToCountPromise = this.getIconToCountMap(); | ||||||
| 
 | 
 | ||||||
|         this.$iconList.empty(); |         this.$iconList.empty(); | ||||||
| @ -165,8 +158,10 @@ export default class NoteIconWidget extends NoteContextAwareWidget { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const {icons} = (await import('./icon_list.js')).default; |         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 => { |         const filteredIcons = icons.filter(icon => { | ||||||
|             if (categoryId && icon.category_id !== categoryId) { |             if (categoryId && icon.category_id !== categoryId) { | ||||||
| @ -182,8 +177,6 @@ export default class NoteIconWidget extends NoteContextAwareWidget { | |||||||
|             return true; |             return true; | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         const iconToCount = await iconToCountPromise; |  | ||||||
| 
 |  | ||||||
|         filteredIcons.sort((a, b) => { |         filteredIcons.sort((a, b) => { | ||||||
|             const countA = iconToCount[a.className] || 0; |             const countA = iconToCount[a.className] || 0; | ||||||
|             const countB = iconToCount[b.className] || 0; |             const countB = iconToCount[b.className] || 0; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam