This repository was archived by the owner on Mar 14, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +22
-12
lines changed Expand file tree Collapse file tree 4 files changed +22
-12
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' svelte-query-pocketbase ' : patch
3+ ---
4+
5+ fix: change how queries are invalidated
Original file line number Diff line number Diff line change @@ -179,10 +179,15 @@ export const createCollectionQuery = <
179179 await unsubscribePromise
180180 ) ( ) ;
181181 if (
182- ! collection . client . realtime [ 'hasSubscriptionListeners' ] ( collection . collectionIdOrName )
182+ ! collection . client . realtime [ 'hasSubscriptionListeners' ] (
183+ collection . collectionIdOrName
184+ ) ||
185+ Object . keys ( queryParams ?? { } ) . length > 0
183186 ) {
184187 console . log (
185- `(C) ${ JSON . stringify ( queryKey ) } : no realtime listeners, marking query as stale.`
188+ `(C) ${ JSON . stringify (
189+ queryKey
190+ ) } : no realtime listeners or query has queryParams, marking query as stale.`
186191 ) ;
187192 queryClient . invalidateQueries ( { queryKey, exact : true } ) ;
188193 }
Original file line number Diff line number Diff line change @@ -303,14 +303,8 @@ export const createInfiniteCollectionQuery = <
303303 await (
304304 await unsubscribePromise
305305 ) ( ) ;
306- if (
307- ! collection . client . realtime [ 'hasSubscriptionListeners' ] ( collection . collectionIdOrName )
308- ) {
309- console . log (
310- `(IC) ${ JSON . stringify ( queryKey ) } : no realtime listeners, marking query as stale.`
311- ) ;
312- queryClient . invalidateQueries ( { queryKey, exact : true } ) ;
313- }
306+ console . log ( `(IC) ${ JSON . stringify ( queryKey ) } : marking query as stale.` ) ;
307+ queryClient . invalidateQueries ( { queryKey, exact : true } ) ;
314308 } ) ( ) ;
315309 return unsubscriber ( ) ;
316310 } ;
Original file line number Diff line number Diff line change @@ -172,11 +172,17 @@ export const createRecordQuery = <
172172 if (
173173 ! collection . client . realtime [ 'hasSubscriptionListeners' ] (
174174 `${ collection . collectionIdOrName } /${ id } `
175- )
175+ ) ||
176+ Object . keys ( queryParams ?? { } ) . length > 0
176177 ) {
177178 console . log (
178- `(R) ${ JSON . stringify ( queryKey ) } : no realtime listeners, marking query as stale.`
179+ `(R) ${ JSON . stringify (
180+ queryKey
181+ ) } : no realtime listeners or query has queryParams, marking query as stale.`
179182 ) ;
183+ // todo: correctly derive queryKey to mark as invalid
184+ // todo: ensure that if a $store was passed into filterFunction,
185+ // only the value when query was created with is used even after the $store's value changes
180186 queryClient . invalidateQueries ( { queryKey, exact : true } ) ;
181187 }
182188 } ) ( ) ;
You can’t perform that action at this time.
0 commit comments