mirror of
https://github.com/zadam/trilium.git
synced 2025-11-08 14:25:51 +01:00
chore(react/note_icon): sort by count
This commit is contained in:
@@ -56,11 +56,11 @@ function NoteIconList() {
|
||||
|
||||
useEffect(() => {
|
||||
async function loadIcons() {
|
||||
const iconToCount = await getIconToCountMap();
|
||||
if (!fullIconData) {
|
||||
fullIconData = (await import("./icon_list.js")).default;
|
||||
}
|
||||
|
||||
// Filter by text and/or category.
|
||||
let icons: Icon[] = fullIconData.icons;
|
||||
if (search || categoryId) {
|
||||
icons = icons.filter((icon) => {
|
||||
@@ -78,6 +78,17 @@ function NoteIconList() {
|
||||
});
|
||||
}
|
||||
|
||||
// Sort by count.
|
||||
const iconToCount = await getIconToCountMap();
|
||||
if (iconToCount) {
|
||||
icons.sort((a, b) => {
|
||||
const countA = iconToCount[a.className ?? ""] || 0;
|
||||
const countB = iconToCount[b.className ?? ""] || 0;
|
||||
|
||||
return countB - countA;
|
||||
});
|
||||
}
|
||||
|
||||
setIconData({
|
||||
iconToCount,
|
||||
icons,
|
||||
|
||||
Reference in New Issue
Block a user