Stop feed pagination after we get dupes back
This commit is contained in:
+27
-14
@@ -246,26 +246,39 @@ export function useGetPopularFeedsQuery(options?: GetPopularFeedsOptions) {
|
|||||||
(
|
(
|
||||||
data: InfiniteData<AppBskyUnspeccedGetPopularFeedGenerators.OutputSchema>,
|
data: InfiniteData<AppBskyUnspeccedGetPopularFeedGenerators.OutputSchema>,
|
||||||
) => {
|
) => {
|
||||||
|
const seen = new Set()
|
||||||
const {savedFeeds, hasSession: hasSessionInner} = selectArgs
|
const {savedFeeds, hasSession: hasSessionInner} = selectArgs
|
||||||
return {
|
return {
|
||||||
...data,
|
...data,
|
||||||
pages: data.pages.map(page => {
|
pages: data.pages.map(page => {
|
||||||
|
let __tempHasDuplicatesStopPagination__ = false
|
||||||
|
|
||||||
|
const feeds = page.feeds.filter(feed => {
|
||||||
|
if (seen.has(feed.uri)) {
|
||||||
|
__tempHasDuplicatesStopPagination__ = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
seen.add(feed.uri)
|
||||||
|
if (
|
||||||
|
!hasSessionInner &&
|
||||||
|
KNOWN_AUTHED_ONLY_FEEDS.includes(feed.uri)
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const alreadySaved = Boolean(
|
||||||
|
savedFeeds?.find(f => {
|
||||||
|
return f.value === feed.uri
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
return !alreadySaved
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...page,
|
...page,
|
||||||
feeds: page.feeds.filter(feed => {
|
cursor: __tempHasDuplicatesStopPagination__
|
||||||
if (
|
? undefined
|
||||||
!hasSessionInner &&
|
: page.cursor,
|
||||||
KNOWN_AUTHED_ONLY_FEEDS.includes(feed.uri)
|
feeds,
|
||||||
) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const alreadySaved = Boolean(
|
|
||||||
savedFeeds?.find(f => {
|
|
||||||
return f.value === feed.uri
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
return !alreadySaved
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user