chore(react/note_icon): sort by count

This commit is contained in:
Elian Doran
2025-08-21 15:05:55 +03:00
parent ef018e22d6
commit b20ffdf7db
2 changed files with 12 additions and 29 deletions

View File

@@ -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,