Refetch empty feed on focus (#7139)
This commit is contained in:
@@ -187,12 +187,16 @@ let PostFeed = ({
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (await pollLatest(data.pages[0])) {
|
if (await pollLatest(data.pages[0])) {
|
||||||
onHasNew(true)
|
if (isEmpty) {
|
||||||
|
refetch()
|
||||||
|
} else {
|
||||||
|
onHasNew(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Poll latest failed', {feed, message: String(e)})
|
logger.error('Poll latest failed', {feed, message: String(e)})
|
||||||
}
|
}
|
||||||
}, [feed, data, isFetching, onHasNew, enabled, disablePoll])
|
}, [feed, data, isFetching, isEmpty, onHasNew, enabled, disablePoll, refetch])
|
||||||
|
|
||||||
const myDid = currentAccount?.did || ''
|
const myDid = currentAccount?.did || ''
|
||||||
const onPostCreated = React.useCallback(() => {
|
const onPostCreated = React.useCallback(() => {
|
||||||
@@ -220,20 +224,15 @@ let PostFeed = ({
|
|||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (enabled && !disablePoll) {
|
if (enabled && !disablePoll) {
|
||||||
const timeSinceFirstLoad = Date.now() - lastFetchRef.current
|
const timeSinceFirstLoad = Date.now() - lastFetchRef.current
|
||||||
// DISABLED need to check if this is causing random feed refreshes -prf
|
if (
|
||||||
/*if (timeSinceFirstLoad > REFRESH_AFTER) {
|
(isEmpty || timeSinceFirstLoad > CHECK_LATEST_AFTER) &&
|
||||||
// do a full refresh
|
|
||||||
scrollElRef?.current?.scrollToOffset({offset: 0, animated: false})
|
|
||||||
queryClient.resetQueries({queryKey: RQKEY(feed)})
|
|
||||||
} else*/ if (
|
|
||||||
timeSinceFirstLoad > CHECK_LATEST_AFTER &&
|
|
||||||
checkForNewRef.current
|
checkForNewRef.current
|
||||||
) {
|
) {
|
||||||
// check for new on enable (aka on focus)
|
// check for new on enable (aka on focus)
|
||||||
checkForNewRef.current()
|
checkForNewRef.current()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [enabled, disablePoll, feed, queryClient, scrollElRef])
|
}, [enabled, disablePoll, feed, queryClient, scrollElRef, isEmpty])
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
let cleanup1: () => void | undefined, cleanup2: () => void | undefined
|
let cleanup1: () => void | undefined, cleanup2: () => void | undefined
|
||||||
const subscription = AppState.addEventListener('change', nextAppState => {
|
const subscription = AppState.addEventListener('change', nextAppState => {
|
||||||
|
|||||||
Reference in New Issue
Block a user