Grab-bag of post-feed improvements (#2140)
* Sanity check against cases where empty pages may occur * Use the mergefeed as an emergency fallback to an empty feed * Check for new posts on focus
This commit is contained in:
parent
52a0cb8fac
commit
040ce03215
5 changed files with 24 additions and 6 deletions
|
@ -132,13 +132,20 @@ let Feed = ({
|
|||
|
||||
React.useEffect(() => {
|
||||
// we store the interval handler in a ref to avoid needless
|
||||
// reassignments of the interval
|
||||
// reassignments in other effects
|
||||
checkForNewRef.current = checkForNew
|
||||
}, [checkForNew])
|
||||
React.useEffect(() => {
|
||||
if (enabled && checkForNewRef.current) {
|
||||
// check for new on enable (aka on focus)
|
||||
checkForNewRef.current()
|
||||
}
|
||||
}, [enabled])
|
||||
React.useEffect(() => {
|
||||
if (!pollInterval) {
|
||||
return
|
||||
}
|
||||
// check for new on interval
|
||||
const i = setInterval(() => checkForNewRef.current?.(), pollInterval)
|
||||
return () => clearInterval(i)
|
||||
}, [pollInterval])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue