Select, don't mutate (#4541)

zio/stable
Eric Bailey 2024-06-17 11:22:39 -05:00 committed by GitHub
parent ba2fadb661
commit f5f3bd8130
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 19 deletions

View File

@ -234,26 +234,28 @@ export function useGetPopularFeedsQuery(options?: GetPopularFeedsOptions) {
data: InfiniteData<AppBskyUnspeccedGetPopularFeedGenerators.OutputSchema>,
) => {
const {savedFeeds, hasSession: hasSessionInner} = selectArgs
data?.pages.map(page => {
page.feeds = page.feeds.filter(feed => {
if (
!hasSessionInner &&
KNOWN_AUTHED_ONLY_FEEDS.includes(feed.uri)
) {
return false
}
const alreadySaved = Boolean(
savedFeeds?.find(f => {
return f.value === feed.uri
return {
...data,
pages: data.pages.map(page => {
return {
...page,
feeds: page.feeds.filter(feed => {
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 !alreadySaved
})
return page
})
return data
}
}),
}
},
[selectArgs /* Don't change. Everything needs to go into selectArgs. */],
),