File tree Expand file tree Collapse file tree 5 files changed +37
-2
lines changed
Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,8 @@ VITE_DEV_PASSWORD=Password12345678
8888API_BASE_URL = http://localhost:5500
8989# The number of miliseconds to delay the result of HTTP requests in development
9090VITE_DEV_NETWORK_LATENCY = 0
91+ # Whether to force clear queries when the pathname changes
92+ VITE_DEV_FORCE_CLEAR_QUERY_CACHE = false
9193# Plausable analytics config (optional, set both to an empty string to disable)
9294PLAUSIBLE_BASE_URL =
9395PLAUSIBLE_WEB_DATA_DOMAIN =
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { sessionRoute } from './features/session';
1616import { uploadRoute } from './features/upload' ;
1717import { userRoute } from './features/user' ;
1818import { DisclaimerProvider } from './providers/DisclaimerProvider' ;
19+ import { ForceClearQueryCacheProvider } from './providers/ForceClearQueryCacheProvider' ;
1920import { WalkthroughProvider } from './providers/WalkthroughProvider' ;
2021import { useAppStore } from './store' ;
2122
@@ -33,7 +34,9 @@ const protectedRoutes: RouteObject[] = [
3334 element : (
3435 < DisclaimerProvider >
3536 < WalkthroughProvider >
36- < Layout />
37+ < ForceClearQueryCacheProvider >
38+ < Layout />
39+ </ ForceClearQueryCacheProvider >
3740 </ WalkthroughProvider >
3841 </ DisclaimerProvider >
3942 ) ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const $Config = z.object({
1111 . optional ( ) ,
1212 dev : z . object ( {
1313 isBypassAuthEnabled : $BooleanString . optional ( ) ,
14+ isForceClearQueryCacheEnabled : $BooleanString . optional ( ) ,
1415 networkLatency : z . coerce . number ( ) . int ( ) . nonnegative ( ) . optional ( ) ,
1516 password : z . string ( ) . min ( 1 ) . optional ( ) ,
1617 username : z . string ( ) . min ( 1 ) . optional ( )
@@ -38,6 +39,7 @@ export const config = await $Config
3839 : undefined ,
3940 dev : {
4041 isBypassAuthEnabled : import . meta. env . VITE_DEV_BYPASS_AUTH ,
42+ isForceClearQueryCacheEnabled : import . meta. env . VITE_DEV_FORCE_CLEAR_QUERY_CACHE ,
4143 networkLatency : import . meta. env . VITE_DEV_NETWORK_LATENCY ,
4244 password : import . meta. env . VITE_DEV_PASSWORD ,
4345 username : import . meta. env . VITE_DEV_USERNAME
Original file line number Diff line number Diff line change 1+ import { Fragment , useEffect } from 'react' ;
2+
3+ import { useQueryClient } from '@tanstack/react-query' ;
4+ import { useLocation } from 'react-router-dom' ;
5+
6+ import { config } from '@/config' ;
7+
8+ let ForceClearQueryCacheProvider : React . FC < { children : React . ReactNode } > ;
9+
10+ if ( config . dev . isForceClearQueryCacheEnabled ) {
11+ // eslint-disable-next-line react/function-component-definition
12+ ForceClearQueryCacheProvider = function ForceClearQueryCacheProvider ( { children } ) {
13+ const queryClient = useQueryClient ( ) ;
14+ const location = useLocation ( ) ;
15+
16+ useEffect ( ( ) => {
17+ //queryClient.clear();
18+ queryClient . clear ( ) ;
19+ } , [ location . pathname ] ) ;
20+
21+ return < > { children } </ > ;
22+ } ;
23+ } else {
24+ ForceClearQueryCacheProvider = Fragment ;
25+ }
26+
27+ export { ForceClearQueryCacheProvider } ;
Original file line number Diff line number Diff line change 66// All of these should be undefined in production
77interface ImportMetaDevEnv {
88 readonly VITE_DEV_BYPASS_AUTH ?: string ;
9+ readonly VITE_DEV_FORCE_CLEAR_QUERY_CACHE ?: string ;
10+ readonly VITE_DEV_NETWORK_LATENCY ?: string ;
911 readonly VITE_DEV_PASSWORD ?: string ;
1012 readonly VITE_DEV_USERNAME ?: string ;
1113}
@@ -19,7 +21,6 @@ interface ImportMetaEnv extends ImportMetaDevEnv {
1921 readonly LICENSE_URL ?: string ;
2022 readonly PLAUSIBLE_BASE_URL ?: string ;
2123 readonly PLAUSIBLE_WEB_DATA_DOMAIN ?: string ;
22- readonly VITE_DEV_NETWORK_LATENCY ?: string ;
2324}
2425
2526interface ImportMeta {
You can’t perform that action at this time.
0 commit comments