wait for preferences before showing feeds
This commit is contained in:
@@ -32,8 +32,11 @@ 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 {
|
||||||
useSavedFeeds()
|
data: savedFeedsAndLists,
|
||||||
|
isLoading: isLoadingSavedFeeds,
|
||||||
|
isFetchedAfterMount: isFetchedSavedFeeds,
|
||||||
|
} = 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)
|
||||||
.map(f => f.view) as AppBskyFeedDefs.GeneratorView[]
|
.map(f => f.view) as AppBskyFeedDefs.GeneratorView[]
|
||||||
@@ -46,15 +49,21 @@ 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(
|
const suggestedFeeds =
|
||||||
popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)),
|
isFetchedSavedFeeds && !isLoadingSavedFeeds && !isLoadingPopularFeeds
|
||||||
)
|
? savedFeeds.concat(
|
||||||
|
popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)),
|
||||||
|
)
|
||||||
|
: 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 ||
|
||||||
|
isLoadingSavedFeeds ||
|
||||||
|
isLoadingPopularFeeds ||
|
||||||
|
isFetchingSearchedFeeds
|
||||||
|
|
||||||
const renderItem = ({
|
const renderItem = ({
|
||||||
item,
|
item,
|
||||||
|
|||||||
Reference in New Issue
Block a user