Skip to content

Commit

Permalink
Change 'backwards' to 'backward'
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Oct 27, 2024
1 parent fd915ce commit 2adfa58
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/toolkit/src/query/core/apiState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ type BaseQuerySubState<
*/
hasNextPage?: boolean
hasPreviousPage?: boolean
direction?: 'forward' | 'backwards'
direction?: 'forward' | 'backward'
param?: QueryArgFrom<D>
}

Expand Down Expand Up @@ -248,7 +248,7 @@ export type InfiniteQuerySubState<
isFetchingNextPage?: boolean
isFetchingPreviousPage?: boolean
param?: PageParamFrom<D>
direction?: 'forward' | 'backwards'
direction?: 'forward' | 'backward'
}
: never

Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/core/buildInitiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export type StartInfiniteQueryActionCreatorOptions<
subscribe?: boolean
forceRefetch?: boolean | number
subscriptionOptions?: SubscriptionOptions
direction?: 'forward' | 'backwards'
direction?: 'forward' | 'backward'
[forceQueryFnSymbol]?: () => QueryReturnValue
param?: unknown
previous?: boolean
Expand Down
5 changes: 1 addition & 4 deletions packages/toolkit/src/query/core/buildSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ export function buildSlice({
'direction' in arg
) {
substate.param = arg.param
substate.direction = arg.direction as
| 'forward'
| 'backwards'
| undefined
substate.direction = arg.direction as 'forward' | 'backward' | undefined
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/query/core/buildThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export type InfiniteQueryThunkArg<
endpointName: string
param: unknown
previous?: boolean
direction?: 'forward' | 'backwards'
direction?: 'forward' | 'backward'
}

type MutationThunkArg = {
Expand Down Expand Up @@ -547,7 +547,7 @@ export function buildThunks<
// If the thunk specified a direction and we do have at least one page,
// fetch the next or previous page
if ('direction' in arg && arg.direction && existingData.pages.length) {
const previous = arg.direction === 'backwards'
const previous = arg.direction === 'backward'
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam
const param = pageParamFn(
endpointDefinition.infiniteQueryOptions,
Expand Down
8 changes: 4 additions & 4 deletions packages/toolkit/src/query/react/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ export type LazyInfiniteQueryTrigger<
*/
(
arg: QueryArgFrom<D>,
direction: 'forward' | 'backwards',
direction: 'forward' | 'backward',
): InfiniteQueryActionCreatorResult<D>
}

Expand Down Expand Up @@ -1312,7 +1312,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
isFetching && currentState.direction === 'forward'

const isFetchingPreviousPage =
isFetching && currentState.direction === 'backwards'
isFetching && currentState.direction === 'backward'

return {
...currentState,
Expand Down Expand Up @@ -1830,7 +1830,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
}, [stableSubscriptionOptions])

const trigger: LazyInfiniteQueryTrigger<any> = useCallback(
function (arg: unknown, direction: 'forward' | 'backwards') {
function (arg: unknown, direction: 'forward' | 'backward') {
let promise: InfiniteQueryActionCreatorResult<any>

batch(() => {
Expand Down Expand Up @@ -1978,7 +1978,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({

const fetchPreviousPage = useCallback(() => {
//if (!hasPreviousPage) return
return trigger(arg, 'backwards')
return trigger(arg, 'backward')
}, [trigger, arg])

return useMemo(
Expand Down

0 comments on commit 2adfa58

Please sign in to comment.