File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
packages/toolkit/src/query/core/buildMiddleware Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,16 @@ export const buildInvalidationByTagsHandler: InternalHandlerBuilder = ({
73
73
}
74
74
}
75
75
76
+ function hasPendingRequests ( state : CombinedState < EndpointDefinitions , string , string > ) {
77
+ for ( const key in state . queries ) {
78
+ if ( state . queries [ key ] ?. status === QueryStatus . pending ) return true ;
79
+ }
80
+ for ( const key in state . mutations ) {
81
+ if ( state . mutations [ key ] ?. status === QueryStatus . pending ) return true ;
82
+ }
83
+ return false ;
84
+ }
85
+
76
86
function invalidateTags (
77
87
newTags : readonly FullTagDescription < string > [ ] ,
78
88
mwApi : SubMiddlewareApi
@@ -82,13 +92,8 @@ export const buildInvalidationByTagsHandler: InternalHandlerBuilder = ({
82
92
83
93
pendingTagInvalidations . push ( ...newTags )
84
94
85
- if ( state . config . invalidationBehavior === 'delayed' ) {
86
- const hasPendingRequests = [
87
- ...Object . values ( state . queries ) ,
88
- ...Object . values ( state . mutations ) ,
89
- ] . some ( ( x ) => x ?. status === QueryStatus . pending )
90
-
91
- if ( hasPendingRequests ) return
95
+ if ( state . config . invalidationBehavior === 'delayed' && hasPendingRequests ( state ) ) {
96
+ return
92
97
}
93
98
94
99
const tags = pendingTagInvalidations
You can’t perform that action at this time.
0 commit comments