Prefetch adjacent Home pages (#6904)
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user