fix: refine widget modernization
This commit is contained in:
50 files changed
+292
-386
No files matched your search
@@ -484,8 +484,7 @@ function CustomApiWidgetInner({
|
||||
const tCustomWidget = useScopedI18n("customWidget");
|
||||
const safeInterval = Number.isFinite(refreshInterval) ? refreshInterval : 30;
|
||||
const intervalMs = Math.max(1000, safeInterval * 1000);
|
||||
const persistedState = widgetStateRef?.current?.customApi as { pollingPaused?: boolean } | undefined;
|
||||
const [pollingPaused, setPollingPaused] = useState(persistedState?.pollingPaused === true);
|
||||
const [pollingPaused, setPollingPaused] = useState(false);
|
||||
const { data, isLoading, error, refetch, isFetching } = clientApi.widget.customApi.getData.useQuery(
|
||||
{ definitionId },
|
||||
{
|
||||
@@ -506,14 +505,6 @@ function CustomApiWidgetInner({
|
||||
const canTogglePolling = Boolean(data) && dataType !== "actionButton" && dataType !== "disabled";
|
||||
const togglePolling = useCallback(() => setPollingPaused((value) => !value), []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!widgetStateRef) return;
|
||||
widgetStateRef.current = {
|
||||
...widgetStateRef.current,
|
||||
customApi: { pollingPaused },
|
||||
};
|
||||
}, [pollingPaused, widgetStateRef]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!widgetStateRef) return;
|
||||
if (canTogglePolling) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("customApi", {
|
||||
icon: IconApi,
|
||||
queryKey: [["widget", "customApi"]],
|
||||
contextActions({ options, widgetStateRef }) {
|
||||
return [
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user