Skip to content

Commit

Permalink
Fix invalidateTags
Browse files Browse the repository at this point in the history
  • Loading branch information
manceauJb committed Sep 28, 2022
1 parent 27cf109 commit ba1ba8a
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ export const build: SubMiddlewareBuilder = ({
const valuesArray = Array.from(toInvalidate.values())
for (const { queryCacheKey } of valuesArray) {
const querySubState = state.queries[queryCacheKey]
const subscriptionSubState = state.subscriptions[queryCacheKey] || {}
const subscriptionSubState = state.subscriptions[queryCacheKey] ?? {}

if (!querySubState) continue

if (Object.keys(subscriptionSubState).length === 0) {
mwApi.dispatch(
removeQueryResult({
queryCacheKey: queryCacheKey as QueryCacheKey,
})
)
} else if (querySubState.status !== QueryStatus.uninitialized) {
mwApi.dispatch(refetchQuery(querySubState, queryCacheKey))
if (querySubState) {
if (Object.keys(subscriptionSubState).length === 0) {
mwApi.dispatch(
removeQueryResult({
queryCacheKey: queryCacheKey as QueryCacheKey,
})
)
} else if (querySubState.status !== QueryStatus.uninitialized) {
mwApi.dispatch(refetchQuery(querySubState, queryCacheKey))
}
}
}
})
Expand Down

0 comments on commit ba1ba8a

Please sign in to comment.