Skip to content

Commit 33c6bd2

Browse files
GeorchWmarkerikson
authored andcommitted
Inline hasPendingRequests again
1 parent 48c776c commit 33c6bd2

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

packages/toolkit/src/query/core/buildMiddleware/invalidationByTags.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ export const buildInvalidationByTagsHandler: InternalHandlerBuilder = ({
7575
}
7676
}
7777

78-
function hasPendingRequests(
79-
state: CombinedState<EndpointDefinitions, string, string>
80-
) {
81-
return Object.values({
82-
...state.queries,
83-
...state.mutations,
84-
}).some((x) => x?.status === QueryStatus.pending)
85-
}
86-
8778
function invalidateTags(
8879
newTags: readonly FullTagDescription<string>[],
8980
mwApi: SubMiddlewareApi
@@ -93,8 +84,13 @@ export const buildInvalidationByTagsHandler: InternalHandlerBuilder = ({
9384

9485
pendingTagInvalidations.push(...newTags)
9586

96-
if (!state.config.invalidateImmediately && hasPendingRequests(state)) {
97-
return
87+
if (!state.config.invalidateImmediately) {
88+
const hasPendingRequests = Object.values({
89+
...state.queries,
90+
...state.mutations,
91+
}).some((x) => x?.status === QueryStatus.pending)
92+
93+
if (hasPendingRequests) return
9894
}
9995

10096
const tags = pendingTagInvalidations

0 commit comments

Comments
 (0)