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:
31 files changed
+124
-117
No files matched your search
@@ -70,7 +70,7 @@ export default function BeszelSystemStatsWidget({
|
||||
} = clientApi.widget.beszel.getSystems.useQuery({ integrationIds });
|
||||
|
||||
const systems = useMemo(
|
||||
() => systemsResult.flatMap((r) => r.systems.map((s) => ({ value: s.id, label: s.name }))),
|
||||
() => systemsResult.flatMap((r) => (r.systems ?? []).map((s) => ({ value: s.id, label: s.name }))),
|
||||
[systemsResult],
|
||||
);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ export const { definition, componentLoader } = createWidgetDefinition("beszelSys
|
||||
isPending,
|
||||
isError,
|
||||
} = clientApi.widget.beszel.getSystems.useQuery({ integrationIds }, { enabled: integrationIds.length > 0 });
|
||||
const selectData = data.flatMap((r) => r.systems.map((s) => ({ value: s.id, label: s.name })));
|
||||
const selectData = data.flatMap((r) => (r.systems ?? []).map((s) => ({ value: s.id, label: s.name })));
|
||||
return { data: selectData, isPending, isError };
|
||||
},
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user