Update useAutoPagination max attempts value (#11623)

This commit is contained in:
Eric Bailey
2026-08-31 17:48:38 -05:00
committed by GitHub
parent bfde8e60c2
commit c28b858030
2 changed files with 11 additions and 3 deletions
+2 -2
View File
@@ -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 -1
View File
@@ -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 {