Wait for preferences before showing suggested feeds (#4618)
parent
bce3338a02
commit
9e89ddeb1c
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue