Stop feed pagination after we get dupes back

This commit is contained in:
Eric Bailey
2024-06-21 16:27:27 -05:00
parent 0a0c738790
commit 795f94c3d8
+17 -4
View File
@@ -246,13 +246,19 @@ 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 => {
return { let __tempHasDuplicatesStopPagination__ = false
...page,
feeds: page.feeds.filter(feed => { const feeds = page.feeds.filter(feed => {
if (seen.has(feed.uri)) {
__tempHasDuplicatesStopPagination__ = true
return false
}
seen.add(feed.uri)
if ( if (
!hasSessionInner && !hasSessionInner &&
KNOWN_AUTHED_ONLY_FEEDS.includes(feed.uri) KNOWN_AUTHED_ONLY_FEEDS.includes(feed.uri)
@@ -265,7 +271,14 @@ export function useGetPopularFeedsQuery(options?: GetPopularFeedsOptions) {
}), }),
) )
return !alreadySaved return !alreadySaved
}), })
return {
...page,
cursor: __tempHasDuplicatesStopPagination__
? undefined
: page.cursor,
feeds,
} }
}), }),
} }