mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
cache icon count to make filtering more responsive on slower connections, #4044
This commit is contained in:
@@ -141,7 +141,8 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
async renderDropdown() {
|
||||
const iconToCountPromise = this.getIconToCountMap();
|
||||
const iconToCount = await this.getIconToCountMap();
|
||||
const {icons} = (await import('./icon_list.js')).default;
|
||||
|
||||
this.$iconList.empty();
|
||||
|
||||
@@ -157,9 +158,6 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
||||
);
|
||||
}
|
||||
|
||||
const {icons} = (await import('./icon_list.js')).default;
|
||||
const iconToCount = await iconToCountPromise;
|
||||
|
||||
const categoryId = parseInt(this.$iconCategory.find('option:selected').val());
|
||||
const search = this.$iconSearch.val().trim().toLowerCase();
|
||||
|
||||
@@ -192,9 +190,12 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
||||
}
|
||||
|
||||
async getIconToCountMap() {
|
||||
const {iconClassToCountMap} = await server.get('other/icon-usage');
|
||||
if (!this.iconToCountCache) {
|
||||
this.iconToCountCache = server.get('other/icon-usage');
|
||||
setTimeout(() => this.iconToCountCache = null, 20000); // invalidate cache after 20 seconds
|
||||
}
|
||||
|
||||
return iconClassToCountMap;
|
||||
return (await this.iconToCountCache).iconClassToCountMap;
|
||||
}
|
||||
|
||||
renderIcon(icon) {
|
||||
|
||||
Reference in New Issue
Block a user