Prefetch adjacent Home pages (#6904)

This commit is contained in:
dan
2024-12-03 01:11:11 +00:00
committed by GitHub
parent 2f10be2cfe
commit 996871d88b
3 changed files with 10 additions and 5 deletions
+4 -2
View File
@@ -32,6 +32,7 @@ const POLL_FREQ = 60e3 // 60sec
export function FeedPage({
testID,
isPageFocused,
isPageAdjacent,
feed,
feedParams,
renderEmptyState,
@@ -42,6 +43,7 @@ export function FeedPage({
feed: FeedDescriptor
feedParams?: FeedParams
isPageFocused: boolean
isPageAdjacent: boolean
renderEmptyState: () => JSX.Element
renderEndOfFeed?: () => JSX.Element
savedFeedConfig?: AppBskyActorDefs.SavedFeed
@@ -111,11 +113,11 @@ export function FeedPage({
<FeedFeedbackProvider value={feedFeedback}>
<Feed
testID={testID ? `${testID}-feed` : undefined}
enabled={isPageFocused}
enabled={isPageFocused || isPageAdjacent}
feed={feed}
feedParams={feedParams}
pollInterval={POLL_FREQ}
disablePoll={hasNew}
disablePoll={hasNew || !isPageFocused}
scrollElRef={scrollElRef}
onScrolledDownChange={setIsScrolledDown}
onHasNew={setHasNew}
+2 -2
View File
@@ -216,7 +216,7 @@ let Feed = ({
checkForNewRef.current = checkForNew
}, [checkForNew])
React.useEffect(() => {
if (enabled) {
if (enabled && !disablePoll) {
const timeSinceFirstLoad = Date.now() - lastFetchRef.current
// DISABLED need to check if this is causing random feed refreshes -prf
/*if (timeSinceFirstLoad > REFRESH_AFTER) {
@@ -231,7 +231,7 @@ let Feed = ({
checkForNewRef.current()
}
}
}, [enabled, feed, queryClient, scrollElRef])
}, [enabled, disablePoll, feed, queryClient, scrollElRef])
React.useEffect(() => {
let cleanup1: () => void | undefined, cleanup2: () => void | undefined
const subscription = AppState.addEventListener('change', nextAppState => {