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/state/queries/post-feed.ts | |
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/state/queries/post-feed.ts')
-rw-r--r-- | src/state/queries/post-feed.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/state/queries/post-feed.ts b/src/state/queries/post-feed.ts index dede8a956..9bd1dacb3 100644 --- a/src/state/queries/post-feed.ts +++ b/src/state/queries/post-feed.ts @@ -217,13 +217,17 @@ export function usePostFeedQuery( const {isFetching, hasNextPage, data} = query let count = 0 + let numEmpties = 0 for (const page of data?.pages || []) { + if (page.slices.length === 0) { + numEmpties++ + } for (const slice of page.slices) { count += slice.items.length } } - if (!isFetching && hasNextPage && count < PAGE_SIZE) { + if (!isFetching && hasNextPage && count < PAGE_SIZE && numEmpties < 3) { query.fetchNextPage() } }, [query]) |