Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/toolkit/src/query/core/buildMiddleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
InternalMiddlewareState,
} from './types'
import { buildWindowEventHandler } from './windowEventHandling'
import type { ApiEndpointQuery } from '../module'
export type { ReferenceCacheCollection } from './cacheCollection'
export type {
MutationCacheLifecycleApi,
Expand Down Expand Up @@ -146,17 +147,10 @@ export function buildMiddleware<
QuerySubState<any>,
{ status: QueryStatus.uninitialized }
>,
queryCacheKey: string,
override: Partial<QueryThunkArg> = {},
) {
return queryThunk({
type: 'query',
endpointName: querySubState.endpointName,
originalArgs: querySubState.originalArgs,
return (input.api.endpoints[querySubState.endpointName] as ApiEndpointQuery<any, any>).initiate(querySubState.originalArgs as any, {
subscribe: false,
forceRefetch: true,
queryCacheKey: queryCacheKey as any,
...override,
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const buildInvalidationByTagsHandler: InternalHandlerBuilder = ({
}),
)
} else if (querySubState.status !== QueryStatus.uninitialized) {
mwApi.dispatch(refetchQuery(querySubState, queryCacheKey))
mwApi.dispatch(refetchQuery(querySubState))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/core/buildMiddleware/polling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const buildPollingHandler: InternalHandlerBuilder = ({
pollingInterval: lowestPollingInterval,
timeout: setTimeout(() => {
if (state.config.focused || !skipPollingIfUnfocused) {
api.dispatch(refetchQuery(querySubState, queryCacheKey))
api.dispatch(refetchQuery(querySubState))
}
startNextPoll({ queryCacheKey }, api)
}, lowestPollingInterval),
Expand Down
8 changes: 4 additions & 4 deletions packages/toolkit/src/query/core/buildMiddleware/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
AsyncThunkAction,
Middleware,
MiddlewareAPI,
ThunkAction,
ThunkDispatch,
UnknownAction,
} from '@reduxjs/toolkit'
Expand All @@ -23,6 +24,7 @@ import type {
QueryThunkArg,
ThunkResult,
} from '../buildThunks'
import type { QueryActionCreatorResult } from '../buildInitiate'

export type QueryStateMeta<T> = Record<string, undefined | T>
export type TimeoutId = ReturnType<typeof setTimeout>
Expand Down Expand Up @@ -62,10 +64,8 @@ export interface BuildSubMiddlewareInput
querySubState: Exclude<
QuerySubState<any>,
{ status: QueryStatus.uninitialized }
>,
queryCacheKey: string,
override?: Partial<QueryThunkArg>,
): AsyncThunkAction<ThunkResult, QueryThunkArg, {}>
>
): ThunkAction<QueryActionCreatorResult<any>, any, any, UnknownAction>
isThisApiSliceAction: (action: Action) => boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const buildWindowEventHandler: InternalHandlerBuilder = ({
}),
)
} else if (querySubState.status !== QueryStatus.uninitialized) {
api.dispatch(refetchQuery(querySubState, queryCacheKey))
api.dispatch(refetchQuery(querySubState))
}
}
}
Expand Down