Only poll feed when feed page is focused (#2064)
* Do no poll when screen is not focused * Avoid polling unless focused * Handle homepage in background * Fix the intl:check to ignore comments in diffs --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
This commit is contained in:
parent
f80bd30ef4
commit
9dec9d7276
7 changed files with 26 additions and 13 deletions
|
@ -89,7 +89,7 @@ let Feed = ({
|
|||
const isEmpty = !isFetching && !data?.pages[0]?.slices.length
|
||||
|
||||
const checkForNew = React.useCallback(async () => {
|
||||
if (!data?.pages[0] || isFetching || !onHasNew) {
|
||||
if (!data?.pages[0] || isFetching || !onHasNew || !enabled) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
|
@ -99,7 +99,7 @@ let Feed = ({
|
|||
} catch (e) {
|
||||
logger.error('Poll latest failed', {feed, error: String(e)})
|
||||
}
|
||||
}, [feed, data, isFetching, onHasNew])
|
||||
}, [feed, data, isFetching, onHasNew, enabled])
|
||||
|
||||
React.useEffect(() => {
|
||||
// we store the interval handler in a ref to avoid needless
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue