From e0ac7d5bdcb096d6c23658c34da04bfa19579e4f Mon Sep 17 00:00:00 2001 From: Hailey Date: Mon, 24 Jun 2024 13:37:08 -0700 Subject: [PATCH] handle each possible loading state (#4617) --- src/screens/StarterPack/Wizard/StepFeeds.tsx | 16 ++++++++++++---- src/screens/StarterPack/Wizard/StepProfiles.tsx | 12 +++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/screens/StarterPack/Wizard/StepFeeds.tsx b/src/screens/StarterPack/Wizard/StepFeeds.tsx index 46c4d440..5170edc6 100644 --- a/src/screens/StarterPack/Wizard/StepFeeds.tsx +++ b/src/screens/StarterPack/Wizard/StepFeeds.tsx @@ -32,12 +32,17 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) { const throttledQuery = useThrottledValue(query, 500) const {screenReaderEnabled} = useA11y() - const {data: savedFeedsAndLists} = useSavedFeeds() + const {data: savedFeedsAndLists, isLoading: isLoadingSavedFeeds} = + useSavedFeeds() const savedFeeds = savedFeedsAndLists?.feeds .filter(f => f.type === 'feed' && f.view.uri !== DISCOVER_FEED_URI) .map(f => f.view) as AppBskyFeedDefs.GeneratorView[] - const {data: popularFeedsPages, fetchNextPage} = useGetPopularFeedsQuery({ + const { + data: popularFeedsPages, + fetchNextPage, + isLoading: isLoadingPopularFeeds, + } = useGetPopularFeedsQuery({ limit: 30, }) const popularFeeds = popularFeedsPages?.pages.flatMap(p => p.feeds) ?? [] @@ -45,9 +50,12 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) { popularFeeds.filter(f => !savedFeeds.some(sf => sf.uri === f.uri)), ) - const {data: searchedFeeds, isLoading: isLoadingSearch} = + const {data: searchedFeeds, isFetching: isFetchingSearchedFeeds} = useSearchPopularFeedsQuery({q: throttledQuery}) + const isLoading = + isLoadingSavedFeeds || isLoadingPopularFeeds || isFetchingSearchedFeeds + const renderItem = ({ item, }: ListRenderItemInfo) => { @@ -90,7 +98,7 @@ export function StepFeeds({moderationOpts}: {moderationOpts: ModerationOpts}) { style={{flex: 1}} ListEmptyComponent={ - {isLoadingSearch ? ( + {isLoading ? ( ) : ( p.actors) - const {data: results, isLoading: isLoadingResults} = + const {data: results, isFetching: isFetchingResults} = useActorAutocompleteQuery(query, true, 12) + const isLoading = isLoadingTopPages || isFetchingResults + const renderItem = ({ item, }: ListRenderItemInfo) => { @@ -80,7 +86,7 @@ export function StepProfiles({ onEndReachedThreshold={isNative ? 2 : 0.25} ListEmptyComponent={ - {isLoadingResults ? ( + {isLoading ? ( ) : (