fix: use SuperJSON for cache persistence and add null guards to all widgets

SuperJSON preserves Date/Map/Set types through the Redis cache round-trip,
fixing RangeError crashes from date formatting. Added defensive null/undefined
guards across all widget components to handle useQuery loading states and
potential cache shape mismatches.
This commit is contained in:
Thomas Camlong committed 2026-07-04 10:19:16 +02:00
1 parent e20053b2c1
commit cf075040e8
31 files changed
+124 -117

No files matched your search

@@ -54,12 +54,12 @@ export default function BeszelAlertsWidget({
}, [results]);
const alerts = useMemo(
() => results.flatMap((r) => r.alerts.map((a) => ({ ...a, _key: `${r.integrationId}:${a.id}` }))),
() => results.flatMap((r) => (r.alerts ?? []).map((a) => ({ ...a, _key: `${r.integrationId}:${a.id}` }))),
[results],
);
const history = useMemo(() => {
const all = results.flatMap((r) => r.history.map((h) => ({ ...h, _key: `${r.integrationId}:${h.id}` })));
const all = results.flatMap((r) => (r.history ?? []).map((h) => ({ ...h, _key: `${r.integrationId}:${h.id}` })));
return all
.toSorted((a, b) => new Date(b.created).getTime() - new Date(a.created).getTime())
.slice(0, options.maxHistoryItems);