Update useAutoPagination max attempts value (#11623)
This commit is contained in:
@@ -78,14 +78,14 @@ describe('useAutoPagination', () => {
|
|||||||
const itemCount = 0
|
const itemCount = 0
|
||||||
const {rerender} = renderHook(() => useAutoPagination(value, itemCount, 10))
|
const {rerender} = renderHook(() => useAutoPagination(value, itemCount, 10))
|
||||||
|
|
||||||
for (let i = 1; i < 50; i++) {
|
for (let i = 1; i < 5; i++) {
|
||||||
value = query({
|
value = query({
|
||||||
fetchNextPage,
|
fetchNextPage,
|
||||||
data,
|
data,
|
||||||
})
|
})
|
||||||
rerender(undefined)
|
rerender(undefined)
|
||||||
}
|
}
|
||||||
expect(fetchNextPage).toHaveBeenCalledTimes(49)
|
expect(fetchNextPage).toHaveBeenCalledTimes(4)
|
||||||
|
|
||||||
const second = query({
|
const second = query({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -9,6 +9,14 @@ import {
|
|||||||
import {app} from '#/lexicons'
|
import {app} from '#/lexicons'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The appview does its own `fillPage`, and defaults to 10 pages. Previously
|
||||||
|
* the frontend tried up to 50 pages, thus the MAX_ATTEMPTS of 5 is a
|
||||||
|
* reasonable compromise to match pre-existing behavior and without blowing up
|
||||||
|
* our backend.
|
||||||
|
*/
|
||||||
|
const MAX_ATTEMPTS = 5
|
||||||
|
|
||||||
type AutoPaginationQuery = {
|
type AutoPaginationQuery = {
|
||||||
data?: {pageParams: unknown[]}
|
data?: {pageParams: unknown[]}
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
@@ -75,7 +83,7 @@ export function useAutoPagination(
|
|||||||
.some(param => Object.is(cursorOf(param), currentCursor))
|
.some(param => Object.is(cursorOf(param), currentCursor))
|
||||||
if (repeatedCursor) return
|
if (repeatedCursor) return
|
||||||
attemptCount.current++
|
attemptCount.current++
|
||||||
if (attemptCount.current < 50) {
|
if (attemptCount.current < MAX_ATTEMPTS) {
|
||||||
void query.fetchNextPage()
|
void query.fetchNextPage()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user