fix(widgets): add typed refetchInterval presets to WidgetDefinition
The v1.69.0 caching refactor replaced Redis pub/sub with a global 30s client polling interval. Live monitoring widgets (health-monitoring, Dashdot, dns-hole) that previously refreshed every 5s were stuck at 30s. Adds a typed WidgetRefetchInterval preset (fiveSeconds | never) to WidgetDefinition. Widgets that need faster polling set fiveSeconds; widgets that don't need polling set never (fetch on mount only, manual refresh via context menu). Absence = global 30s default. nine widgets get fiveSeconds (live monitoring) sixteen widgets get never (slow data, mount-only) remaining widgets use the 30s default Also removes inline refetchInterval from docker widget component. Fixes #6268
This commit is contained in:
1 parent
a0034b2cfc
commit
a253dcb7d8
29 files changed
+80
-3
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
import type { PropsWithChildren } from "react";
|
||||
import { useState } from "react";
|
||||
import type { QueryKey } from "@tanstack/react-query";
|
||||
import { QueryClient } from "@tanstack/react-query";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import { ReactQueryStreamedHydration } from "@tanstack/react-query-next-experimental";
|
||||
@@ -33,6 +34,7 @@ import {
|
||||
import { createHeadersCallbackForSource, getTrpcUrl } from "@homarr/api/shared";
|
||||
import { env } from "@homarr/common/env";
|
||||
import { showWarningNotification } from "@homarr/notifications";
|
||||
import { widgetImports } from "@homarr/widgets";
|
||||
|
||||
import { createWidgetQueryPersister } from "./query-cache-persister";
|
||||
|
||||
@@ -90,6 +92,13 @@ export function TRPCReactProvider(props: PropsWithChildren) {
|
||||
},
|
||||
});
|
||||
client.setQueryDefaults([["widget"]], { refetchInterval: queryCacheDefaultRefetchIntervalMs });
|
||||
for (const { definition } of Object.values(widgetImports)) {
|
||||
const def = definition as { refetchInterval?: number | false; queryKey?: QueryKey; kind: string };
|
||||
if (def.refetchInterval === undefined) continue;
|
||||
const key = def.queryKey ?? [["widget", def.kind]];
|
||||
const interval = def.refetchInterval === false ? false : def.refetchInterval * 1000;
|
||||
client.setQueryDefaults(key, { refetchInterval: interval });
|
||||
}
|
||||
return client;
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user