From a873c45e7b1a8140cb5182432e4fd18ca8df6e83 Mon Sep 17 00:00:00 2001 From: Hailey Date: Mon, 24 Jun 2024 14:18:29 -0700 Subject: [PATCH] wait for preferences before showing feeds --- src/screens/StarterPack/Wizard/StepFeeds.tsx | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/screens/StarterPack/Wizard/StepFeeds.tsx b/src/screens/StarterPack/Wizard/StepFeeds.tsx index 5170edc6ef..457bf270ba 100644 --- a/src/screens/StarterPack/Wizard/StepFeeds.tsx +++ b/src/screens/StarterPack/Wizard/StepFeeds.tsx @@ -32,8 +32,11 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) { const throttledQuery = useThrottledValue(query, 500) const {screenReaderEnabled} = useA11y() - const {data: savedFeedsAndLists, isLoading: isLoadingSavedFeeds} = - useSavedFeeds() + const { + data: savedFeedsAndLists, + isLoading: isLoadingSavedFeeds, + isFetchedAfterMount: isFetchedSavedFeeds, + } = useSavedFeeds() const savedFeeds = savedFeedsAndLists?.feeds .filter(f => f.type === 'feed' && f.view.uri !== DISCOVER_FEED_URI) .map(f => f.view) as AppBskyFeedDefs.GeneratorView[] @@ -46,15 +49,21 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) { limit: 30, }) const popularFeeds = popularFeedsPages?.pages.flatMap(p => p.feeds) ?? [] - const suggestedFeeds = savedFeeds.concat( - popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)), - ) + const suggestedFeeds = + isFetchedSavedFeeds && !isLoadingSavedFeeds && !isLoadingPopularFeeds + ? savedFeeds.concat( + popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)), + ) + : undefined const {data: searchedFeeds, isFetching: isFetchingSearchedFeeds} = useSearchPopularFeedsQuery({q: throttledQuery}) const isLoading = - isLoadingSavedFeeds || isLoadingPopularFeeds || isFetchingSearchedFeeds + !isFetchedSavedFeeds || + isLoadingSavedFeeds || + isLoadingPopularFeeds || + isFetchingSearchedFeeds const renderItem = ({ item,