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
|
@ -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])
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue