Wait for preferences before showing suggested feeds (#4618)

zio/stable
Hailey 2024-06-24 15:48:10 -07:00 committed by GitHub
parent bce3338a02
commit 9e89ddeb1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 5 deletions

View File

@ -32,7 +32,7 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
const throttledQuery = useThrottledValue(query, 500) const throttledQuery = useThrottledValue(query, 500)
const {screenReaderEnabled} = useA11y() const {screenReaderEnabled} = useA11y()
const {data: savedFeedsAndLists, isLoading: isLoadingSavedFeeds} = const {data: savedFeedsAndLists, isFetchedAfterMount: isFetchedSavedFeeds} =
useSavedFeeds() useSavedFeeds()
const savedFeeds = savedFeedsAndLists?.feeds const savedFeeds = savedFeedsAndLists?.feeds
.filter(f => f.type === 'feed' && f.view.uri !== DISCOVER_FEED_URI) .filter(f => f.type === 'feed' && f.view.uri !== DISCOVER_FEED_URI)
@ -46,15 +46,23 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) {
limit: 30, limit: 30,
}) })
const popularFeeds = popularFeedsPages?.pages.flatMap(p => p.feeds) ?? [] const popularFeeds = popularFeedsPages?.pages.flatMap(p => p.feeds) ?? []
const suggestedFeeds = savedFeeds.concat(
// If we have saved feeds already loaded, display them immediately
// Then, when popular feeds have loaded we can concat them to the saved feeds
const suggestedFeeds =
savedFeeds || isFetchedSavedFeeds
? popularFeeds
? savedFeeds.concat(
popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)), popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)),
) )
: savedFeeds
: undefined
const {data: searchedFeeds, isFetching: isFetchingSearchedFeeds} = const {data: searchedFeeds, isFetching: isFetchingSearchedFeeds} =
useSearchPopularFeedsQuery({q: throttledQuery}) useSearchPopularFeedsQuery({q: throttledQuery})
const isLoading = const isLoading =
isLoadingSavedFeeds || isLoadingPopularFeeds || isFetchingSearchedFeeds !isFetchedSavedFeeds || isLoadingPopularFeeds || isFetchingSearchedFeeds
const renderItem = ({ const renderItem = ({
item, item,