diff --git a/src/components/Feed.tsx b/src/components/Feed.tsx index 1e338759..087668c7 100644 --- a/src/components/Feed.tsx +++ b/src/components/Feed.tsx @@ -215,14 +215,20 @@ function PageBoundary({ }) { const { ref, inView } = useInView({ threshold: 0, - rootMargin: '800px', // Start loading well before the user reaches this page + rootMargin: '400px', // Start loading before the user reaches this page }); useEffect(() => { - // Trigger next page when this page comes into view + // Trigger next page when ANY page boundary comes into view (not just the last one) + // This prevents race conditions when scrolling fast // Skip page 0 since it auto-loads page 1 - if (inView && pageIndex > 0 && pageIndex === totalPages - 1 && hasNextPage && !isFetchingNextPage) { - onLoadNext(); + if (inView && pageIndex > 0 && hasNextPage && !isFetchingNextPage) { + // Only trigger if this is the last page, OR if we're close to it (within 1 page) + // This prevents triggering page 10 when we're only on page 2 + const isRelevant = pageIndex >= totalPages - 2; + if (isRelevant) { + onLoadNext(); + } } }, [inView, pageIndex, totalPages, hasNextPage, isFetchingNextPage, onLoadNext]); diff --git a/src/hooks/useAuthors.ts b/src/hooks/useAuthors.ts index 60addb24..58b0904f 100644 --- a/src/hooks/useAuthors.ts +++ b/src/hooks/useAuthors.ts @@ -69,7 +69,7 @@ export function useAuthors(pubkeys: string[]) { // individually with more time (5000ms vs 500ms EOSE timeout). const missing = uniquePubkeys.filter(pk => !found.has(pk)); if (missing.length > 0 && readRelayUrls.length > 0) { - console.log('[useAuthors] Loser race for', missing.length, 'missing profiles on', readRelayUrls.length, 'relays'); + console.log('[useAuthors] Loser race for', missing.length, 'missing profiles on', readRelayUrls.length, 'relays:', readRelayUrls); await new Promise((resolve) => { const needed = new Set(missing); let pending = readRelayUrls.length;