fix: address CodeRabbit review findings

- docker-table: inspect refetch result instead of .catch() (TQ v5 compat)
- rssFeed: sort all entries by date before slicing to max posts
- toValidDate: reject null/boolean inputs before Date construction
- system-resources: reset chart history when integrationIds changes
- settleIntegrationQueries: wrap fn in async boundary for safe allSettled
This commit is contained in:
Thomas Camlong committed 2026-06-27 12:13:52 +02:00
1 parent 45c58c967e
commit 12bf6ee4be
5 files changed
+18 -14

No files matched your search

@@ -163,19 +163,19 @@ export function DockerTable({ initialData }: DockerTableProps) {
});
const relativeTime = useTimeAgo(data?.timestamp ?? new Date());
const mutate = useCallback(() => {
void refetch()
.then(() => {
showSuccessNotification({
title: tDocker("action.refresh.notification.success.title"),
message: tDocker("action.refresh.notification.success.message"),
});
})
.catch(() => {
void refetch().then((result) => {
if (result.isError) {
showErrorNotification({
title: tDocker("action.refresh.notification.error.title"),
message: tDocker("action.refresh.notification.error.message"),
});
});
} else {
showSuccessNotification({
title: tDocker("action.refresh.notification.success.title"),
message: tDocker("action.refresh.notification.success.message"),
});
}
});
}, [refetch, tDocker]);
const containers = data?.containers ?? [];
+2 -2
View File
@@ -40,12 +40,12 @@ export const rssFeedRouter = createTRPCRouter({
logger.warn("RSS feed fetch failed", { url: urls[index], error: result.reason });
return [];
})
.slice(0, input.maximumAmountPosts)
.toSorted((entryA, entryB) => {
return entryA.published && entryB.published
? new Date(entryB.published).getTime() - new Date(entryA.published).getTime()
: 0;
});
})
.slice(0, input.maximumAmountPosts);
}),
});
+1 -1
View File
@@ -13,7 +13,7 @@ export async function settleIntegrationQueries<TIntegration extends IntegrationL
integrations: TIntegration[],
fn: (integration: TIntegration) => Promise<TResult>,
): Promise<TResult[]> {
const settled = await Promise.allSettled(integrations.map(fn));
const settled = await Promise.allSettled(integrations.map(async (integration) => fn(integration)));
return settled.flatMap((result, index) => {
if (result.status === "fulfilled") return [result.value];
const integration = integrations[index];
+1
View File
@@ -18,6 +18,7 @@ export function formatDuration(milliseconds: number) {
}
export const toValidDate = (value: unknown): Date | null => {
if (value == null || typeof value === "boolean") return null;
const date = value instanceof Date ? value : new Date(value as string | number);
return Number.isFinite(date.getTime()) ? date : null;
};
@@ -44,13 +44,16 @@ export default function SystemResources({ integrationIds, options }: WidgetCompo
>(() => (data[0] ? [toChartItem(data[0].healthInfo)] : []));
const lastUpdatedAt = useRef(dataUpdatedAt);
const prevIntegrationIds = useRef(integrationIds);
useEffect(() => {
if (dataUpdatedAt === lastUpdatedAt.current) return;
lastUpdatedAt.current = dataUpdatedAt;
const firstItem = data[0];
if (!firstItem) return;
setItems((prev) => [...prev, toChartItem(firstItem.healthInfo)].slice(-MAX_QUEUE_SIZE));
}, [dataUpdatedAt, data]);
const idsChanged = prevIntegrationIds.current !== integrationIds;
prevIntegrationIds.current = integrationIds;
setItems((prev) => (idsChanged ? [toChartItem(firstItem.healthInfo)] : [...prev, toChartItem(firstItem.healthInfo)].slice(-MAX_QUEUE_SIZE)));
}, [dataUpdatedAt, data, integrationIds]);
const showNetwork =
items.length === 0 || (items.every((item) => item.network !== null) && options.visibleCharts.includes("network"));