Skip to content

Commit

Permalink
Fix return typo and rearranged logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderArvidsson committed Feb 1, 2022
1 parent 8151c8c commit f80108e
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ export const build: SubMiddlewareBuilder = ({
const querySubState = queries[queryCacheKey]
const subscriptionSubState = subscriptions[queryCacheKey]

if (!subscriptionSubState || !querySubState) return
if (!subscriptionSubState || !querySubState) continue

if (Object.keys(subscriptionSubState).length === 0) {
api.dispatch(
removeQueryResult({
queryCacheKey: queryCacheKey as QueryCacheKey,
})
)
} else if (querySubState.status !== QueryStatus.uninitialized) {
const shouldRefetch =
Object.values(subscriptionSubState).some(
(sub) => sub[type] === true
) ||
(Object.values(subscriptionSubState).every(
(sub) => sub[type] === undefined
) &&
state.config[type])
const shouldRefetch =
Object.values(subscriptionSubState).some(
(sub) => sub[type] === true
) ||
(Object.values(subscriptionSubState).every(
(sub) => sub[type] === undefined
) &&
state.config[type])

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

0 comments on commit f80108e

Please sign in to comment.