Skip to content

Commit 0065e45

Browse files
committed
Change useQuery defaults to avoid refetching
useQuery refetches on eg. window change. So if you click away from the tab and then click on the AcidWatch tab, then AcidWatch will refetch eg. the models, or at worst, restart the simulation. Very silly!
1 parent ea1ea85 commit 0065e45

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

frontend/src/contexts/SimulationContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const SimulationResultsProvider: React.FC<{ children: ReactNode }> = ({ c
2020
queryKey: ["startSimluation", modelInput],
2121
queryFn: async () => startSimulation(modelInput!),
2222
enabled: modelInput !== undefined,
23+
gcTime: Infinity,
2324
});
2425

2526
const { data: simulationResults, isLoading } = useQuery({

frontend/src/hooks/useSimulationQueriesResult.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ export const useSimulationQueries = (experiments: ExperimentResult[]): UseSimula
4848
experiment: experiment,
4949
}),
5050
retryOnMount: false,
51-
staleTime: "static",
5251
gcTime: Infinity,
53-
refetchOnMount: false,
54-
refetchOnWindowFocus: false,
55-
refetchOnReconnect: false,
5652
};
5753
}),
5854
combine: (queryResults) => queryResults.filter((value) => value.isSuccess).map((value) => value.data),
@@ -66,10 +62,6 @@ export const useSimulationQueries = (experiments: ExperimentResult[]): UseSimula
6662
result: await getResultForSimulation(simulationId.result),
6763
}),
6864
retry: (_failureCount: number, error: Error): boolean => error instanceof ResultIsPending,
69-
retryOnMount: false,
70-
refetchOnMount: false,
71-
refetchOnWindowFocus: false,
72-
refetchOnReconnect: false,
7365
})),
7466
combine: (queryResults) => {
7567
const data: Record<string, SimulationResults[]> = {};

frontend/src/main.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import { MsalProvider } from "@azure/msal-react";
99
import { msalInstance } from "./services/auth";
1010

1111
const queryClient = new QueryClient();
12+
queryClient.setDefaultOptions({
13+
queries: {
14+
refetchOnWindowFocus: false,
15+
refetchOnReconnect: false,
16+
staleTime: "static",
17+
},
18+
});
1219

1320
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
1421
<React.StrictMode>

0 commit comments

Comments
 (0)