Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refetch empty feed on focus (#7139)

authored by

dan and committed by
GitHub
31d2aa67 20d4266e

+9 -10
+9 -10
src/view/com/posts/PostFeed.tsx
··· 187 187 } 188 188 try { 189 189 if (await pollLatest(data.pages[0])) { 190 - onHasNew(true) 190 + if (isEmpty) { 191 + refetch() 192 + } else { 193 + onHasNew(true) 194 + } 191 195 } 192 196 } catch (e) { 193 197 logger.error('Poll latest failed', {feed, message: String(e)}) 194 198 } 195 - }, [feed, data, isFetching, onHasNew, enabled, disablePoll]) 199 + }, [feed, data, isFetching, isEmpty, onHasNew, enabled, disablePoll, refetch]) 196 200 197 201 const myDid = currentAccount?.did || '' 198 202 const onPostCreated = React.useCallback(() => { ··· 220 224 React.useEffect(() => { 221 225 if (enabled && !disablePoll) { 222 226 const timeSinceFirstLoad = Date.now() - lastFetchRef.current 223 - // DISABLED need to check if this is causing random feed refreshes -prf 224 - /*if (timeSinceFirstLoad > REFRESH_AFTER) { 225 - // do a full refresh 226 - scrollElRef?.current?.scrollToOffset({offset: 0, animated: false}) 227 - queryClient.resetQueries({queryKey: RQKEY(feed)}) 228 - } else*/ if ( 229 - timeSinceFirstLoad > CHECK_LATEST_AFTER && 227 + if ( 228 + (isEmpty || timeSinceFirstLoad > CHECK_LATEST_AFTER) && 230 229 checkForNewRef.current 231 230 ) { 232 231 // check for new on enable (aka on focus) 233 232 checkForNewRef.current() 234 233 } 235 234 } 236 - }, [enabled, disablePoll, feed, queryClient, scrollElRef]) 235 + }, [enabled, disablePoll, feed, queryClient, scrollElRef, isEmpty]) 237 236 React.useEffect(() => { 238 237 let cleanup1: () => void | undefined, cleanup2: () => void | undefined 239 238 const subscription = AppState.addEventListener('change', nextAppState => {