diff --git a/src/components/DashboardView.js b/src/components/DashboardView.js index f9c46e7..b749a41 100644 --- a/src/components/DashboardView.js +++ b/src/components/DashboardView.js @@ -1,4 +1,4 @@ -import { useEffect } from 'react'; +import { useEffect, useMemo } from 'react'; import NotificationPanel from './NotificationPanel'; const DashboardView = ({ @@ -70,6 +70,28 @@ const DashboardView = ({ ntfyPreviewUrl } = notificationProps; + const sortedStores = useMemo(() => { + const list = Array.isArray(stores) ? [...stores] : []; + return list.sort((a, b) => { + const aId = a?.id != null ? String(a.id) : ''; + const bId = b?.id != null ? String(b.id) : ''; + const aInConfig = configMap?.has(aId); + const bInConfig = configMap?.has(bId); + if (aInConfig !== bInConfig) { + return aInConfig ? 1 : -1; + } + const nameA = (a?.name || '').toLocaleLowerCase('de-DE'); + const nameB = (b?.name || '').toLocaleLowerCase('de-DE'); + if (nameA < nameB) { + return -1; + } + if (nameA > nameB) { + return 1; + } + return 0; + }); + }, [stores, configMap]); + return (