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/notifications/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/notifications/feed.ts')
-rw-r--r-- | src/state/queries/notifications/feed.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/state/queries/notifications/feed.ts b/src/state/queries/notifications/feed.ts index 3f9700c79..b8d8d6160 100644 --- a/src/state/queries/notifications/feed.ts +++ b/src/state/queries/notifications/feed.ts @@ -91,11 +91,15 @@ export function useNotificationFeedQuery(opts?: {enabled?: boolean}) { const {isFetching, hasNextPage, data} = query let count = 0 + let numEmpties = 0 for (const page of data?.pages || []) { + if (!page.items.length) { + numEmpties++ + } count += page.items.length } - if (!isFetching && hasNextPage && count < PAGE_SIZE) { + if (!isFetching && hasNextPage && count < PAGE_SIZE && numEmpties < 3) { query.fetchNextPage() } }, [query]) |