@@ -18,13 +18,13 @@ export class QueryObserver<TResult, TError> {
1818 private currentResult ! : QueryResult < TResult , TError >
1919 private previousQueryResult ?: QueryResult < TResult , TError >
2020 private listener ?: UpdateListener < TResult , TError >
21- private initialFetchedCount : number
21+ private initialUpdateCount : number
2222 private staleTimeoutId ?: number
2323 private refetchIntervalId ?: number
2424
2525 constructor ( config : ResolvedQueryConfig < TResult , TError > ) {
2626 this . config = config
27- this . initialFetchedCount = 0
27+ this . initialUpdateCount = 0
2828
2929 // Bind exposed methods
3030 this . clear = this . clear . bind ( this )
@@ -161,6 +161,7 @@ export class QueryObserver<TResult, TError> {
161161 if ( ! this . currentResult . isStale ) {
162162 this . currentResult = { ...this . currentResult , isStale : true }
163163 this . notify ( )
164+ this . config . queryCache . notifyGlobalListeners ( this . currentQuery )
164165 }
165166 } , timeout )
166167 }
@@ -229,7 +230,7 @@ export class QueryObserver<TResult, TError> {
229230
230231 // When the query has not been fetched yet and this is the initial render,
231232 // determine the staleness based on the initialStale or existence of initial data.
232- if ( ! currentResult && ! state . isFetched ) {
233+ if ( ! currentResult && state . isInitialData ) {
233234 if ( typeof config . initialStale === 'function' ) {
234235 isStale = config . initialStale ( )
235236 } else if ( typeof config . initialStale === 'boolean' ) {
@@ -249,10 +250,11 @@ export class QueryObserver<TResult, TError> {
249250 error : state . error ,
250251 failureCount : state . failureCount ,
251252 fetchMore : this . fetchMore ,
252- isFetched : state . isFetched ,
253- isFetchedAfterMount : state . fetchedCount > this . initialFetchedCount ,
253+ isFetched : state . updateCount > 0 ,
254+ isFetchedAfterMount : state . updateCount > this . initialUpdateCount ,
254255 isFetching : state . isFetching ,
255256 isFetchingMore : state . isFetchingMore ,
257+ isInitialData : state . isInitialData ,
256258 isPreviousData,
257259 isStale,
258260 refetch : this . refetch ,
@@ -284,7 +286,7 @@ export class QueryObserver<TResult, TError> {
284286
285287 this . previousQueryResult = this . currentResult
286288 this . currentQuery = query
287- this . initialFetchedCount = query . state . fetchedCount
289+ this . initialUpdateCount = query . state . updateCount
288290 this . updateResult ( )
289291
290292 if ( this . listener ) {
0 commit comments