π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
Update SortItems.js
hypermagicmountain02194a49c7e7
diff --git a/src/utils/SortItems.js b/src/utils/SortItems.jsindex b95c7e83..3d012348 100644--- a/src/utils/SortItems.js+++ b/src/utils/SortItems.js@@ -10,6 +10,11 @@ const byTitle = (items) => [...items].sort((a, b) => ((a.title || '').toLowerCase() > (b.title || '').toLowerCase() ? 1 : -1),);+const byUsage = (items, key) => {+ const counts = readUsage(key);+ const get = (item) => counts[item.id] || 0;+ return [...items].reverse().sort((a, b) => (get(a) < get(b) ? 1 : -1));+};const byProvider = (items) => [...items].sort((a, b) => ((a.provider || '').toLowerCase() > (b.provider || '').toLowerCase() ? 1 : -1),);@@ -18,13 +23,6 @@ const byID = (items) => [...items].sort((a, b) => ((a.id || '').toLowerCase() > (b.id || '').toLowerCase() ? 1 : -1),);--const byUsage = (items, key) => {- const counts = readUsage(key);- const get = (item) => counts[item.id] || 0;- return [...items].reverse().sort((a, b) => (get(a) < get(b) ? 1 : -1));-};-const shuffled = (items) => items.map((value) => ({ value, sort: Math.random() })).sort((a, b) => a.sort - b.sort)@@ -34,16 +32,16 @@ const shuffled = (items) => itemsexport default function sortItems(items, order, sectionTitle = '') {const list = Array.isArray(items) ? items.slice() : [];const ord = order || defaultSortOrder;- if (ord === 'Default') return list;- if (ord === 'Alphabetical') return byTitle(list);- if (ord === 'Alphabetical reverse') return byTitle(list).reverse();- if (ord === 'Most-used') return byUsage(list, localStorageKeys.MOST_USED);- if (ord === 'Last-used') return byUsage(list, localStorageKeys.LAST_USED);- if (ord === 'Provider') return byProvider(list);- if (ord === 'Provider reverse') return byProvider(list).reverse();- if (ord === 'Item ID') return byID(list);- if (ord === 'Item ID reverse') return byID(list).reverse();- if (ord === 'Random') return shuffled(list);+ if (ord === 'default') return list;+ if (ord === 'alphabetical') return byTitle(list);+ if (ord === 'reverse-alphabetical') return byTitle(list).reverse();+ if (ord === 'most-used') return byUsage(list, localStorageKeys.MOST_USED);+ if (ord === 'last-used') return byUsage(list, localStorageKeys.LAST_USED);+ if (ord === 'random') return shuffled(list);+ if (ord === 'provider') return byProvider(list);+ if (ord === 'provider-reverse') return byProvider(list).reverse();+ if (ord === 'itemID') return byID(list);+ if (ord === 'itemID-reverse') return byID(list).reverse();ErrorHandler(`Unknown Sort order '${ord}'${sectionTitle ? ` under '${sectionTitle}'` : ''}`);return list;}