diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-12-07 16:30:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-07 16:30:04 -0800 |
commit | 040ce0321545c7b7588b96e26d988fc19ffbbba3 (patch) | |
tree | 37cce1c17873b00dfd9c5f0b19123f8ec29eda76 /src/view/com/posts/Feed.tsx | |
parent | 52a0cb8faccd0df8250b4b084005d2fd6d12a9ad (diff) | |
download | voidsky-040ce0321545c7b7588b96e26d988fc19ffbbba3.tar.zst |
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
Diffstat (limited to 'src/view/com/posts/Feed.tsx')
-rw-r--r-- | src/view/com/posts/Feed.tsx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index 03fa95eea..43f327c00 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -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]) |