From c28b85803012ceb8fa03755d88cdfe85f4e70384 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 31 Aug 2026 17:48:38 -0500 Subject: [PATCH] Update `useAutoPagination` max attempts value (#11623) --- src/state/queries/util.test.tsx | 4 ++-- src/state/queries/util.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/state/queries/util.test.tsx b/src/state/queries/util.test.tsx index 695ada0697..43f109aaf3 100644 --- a/src/state/queries/util.test.tsx +++ b/src/state/queries/util.test.tsx @@ -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: { diff --git a/src/state/queries/util.ts b/src/state/queries/util.ts index 718b6cf7b8..580ba9493e 100644 --- a/src/state/queries/util.ts +++ b/src/state/queries/util.ts @@ -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 {