Update useAutoPagination max attempts value (#11623)
This commit is contained in:
@@ -78,14 +78,14 @@ describe('useAutoPagination', () => {
|
||||
const itemCount = 0
|
||||
const {rerender} = renderHook(() => useAutoPagination(value, itemCount, 10))
|
||||
|
||||
for (let i = 1; i < 50; i++) {
|
||||
for (let i = 1; i < 5; i++) {
|
||||
value = query({
|
||||
fetchNextPage,
|
||||
data,
|
||||
})
|
||||
rerender(undefined)
|
||||
}
|
||||
expect(fetchNextPage).toHaveBeenCalledTimes(49)
|
||||
expect(fetchNextPage).toHaveBeenCalledTimes(4)
|
||||
|
||||
const second = query({
|
||||
data: {
|
||||
|
||||
@@ -9,6 +9,14 @@ import {
|
||||
import {app} from '#/lexicons'
|
||||
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 = {
|
||||
data?: {pageParams: unknown[]}
|
||||
isLoading: boolean
|
||||
@@ -75,7 +83,7 @@ export function useAutoPagination(
|
||||
.some(param => Object.is(cursorOf(param), currentCursor))
|
||||
if (repeatedCursor) return
|
||||
attemptCount.current++
|
||||
if (attemptCount.current < 50) {
|
||||
if (attemptCount.current < MAX_ATTEMPTS) {
|
||||
void query.fetchNextPage()
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user