mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
sort icons by how much they are used, #3784
This commit is contained in:
29
src/routes/api/other.js
Normal file
29
src/routes/api/other.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const becca = require("../../becca/becca");
|
||||
|
||||
function getIconUsage() {
|
||||
const iconClassToCountMap = {};
|
||||
|
||||
for (const {value: iconClass, noteId} of becca.findAttributes('label', 'iconClass')) {
|
||||
if (noteId.startsWith("_")) {
|
||||
continue; // ignore icons of "system" notes since they were not set by the user
|
||||
}
|
||||
|
||||
if (!iconClass?.trim()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const clazz of iconClass.trim().split(/\s+/)) {
|
||||
if (clazz === 'bx') {
|
||||
continue;
|
||||
}
|
||||
|
||||
iconClassToCountMap[clazz] = (iconClassToCountMap[clazz] || 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return { iconClassToCountMap };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getIconUsage
|
||||
};
|
||||
Reference in New Issue
Block a user