diff options
author | dan <dan.abramov@gmail.com> | 2024-08-30 16:54:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-30 16:54:55 +0100 |
commit | dbbbba1d32cbb96d9ab98eb871f3618df7f6e628 (patch) | |
tree | ef999f211aaa767d8d847c21b08b3cccf340ec2b /src/components/FeedInterstitials.tsx | |
parent | 46b7193a2b8f1a9e804644016692da39e4519458 (diff) | |
download | voidsky-dbbbba1d32cbb96d9ab98eb871f3618df7f6e628.tar.zst |
[Experiment] Suggest profiles in profile (#5030)
* Rename variable to disambiguate with parent scope * More variables where they are used * Inline variables * Add suggestions in profile * Gate it * rm space * Remove header suggestions under gate
Diffstat (limited to 'src/components/FeedInterstitials.tsx')
-rw-r--r-- | src/components/FeedInterstitials.tsx | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/src/components/FeedInterstitials.tsx b/src/components/FeedInterstitials.tsx index e37d2c3e0..65e981f77 100644 --- a/src/components/FeedInterstitials.tsx +++ b/src/components/FeedInterstitials.tsx @@ -1,18 +1,21 @@ import React from 'react' import {View} from 'react-native' import {ScrollView} from 'react-native-gesture-handler' -import {AppBskyFeedDefs, AtUri} from '@atproto/api' +import {AppBskyActorDefs, AppBskyFeedDefs, AtUri} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useNavigation} from '@react-navigation/native' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {NavigationProp} from '#/lib/routes/types' +import {useGate} from '#/lib/statsig/statsig' import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useGetPopularFeedsQuery} from '#/state/queries/feed' +import {FeedDescriptor} from '#/state/queries/post-feed' import {useProfilesQuery} from '#/state/queries/profile' +import {useSuggestedFollowsByActorQuery} from '#/state/queries/suggested-follows' import {useSession} from '#/state/session' import {useProgressGuide} from '#/state/shell/progress-guide' import * as userActionHistory from '#/state/userActionHistory' @@ -173,14 +176,63 @@ function useExperimentalSuggestedUsersQuery() { } } -export function SuggestedFollows() { - const t = useTheme() - const {_} = useLingui() +export function SuggestedFollows({feed}: {feed: FeedDescriptor}) { + const gate = useGate() + const [feedType, feedUri] = feed.split('|') + if (feedType === 'author') { + if (gate('show_follow_suggestions_in_profile')) { + return <SuggestedFollowsProfile did={feedUri} /> + } else { + return null + } + } else { + return <SuggestedFollowsHome /> + } +} + +export function SuggestedFollowsProfile({did}: {did: string}) { + const { + isLoading: isSuggestionsLoading, + data, + error, + } = useSuggestedFollowsByActorQuery({ + did, + }) + return ( + <ProfileGrid + isSuggestionsLoading={isSuggestionsLoading} + profiles={data?.suggestions ?? []} + error={error} + /> + ) +} + +export function SuggestedFollowsHome() { const { isLoading: isSuggestionsLoading, profiles, error, } = useExperimentalSuggestedUsersQuery() + return ( + <ProfileGrid + isSuggestionsLoading={isSuggestionsLoading} + profiles={profiles} + error={error} + /> + ) +} + +export function ProfileGrid({ + isSuggestionsLoading, + error, + profiles, +}: { + isSuggestionsLoading: boolean + profiles: AppBskyActorDefs.ProfileViewDetailed[] + error: Error | null +}) { + const t = useTheme() + const {_} = useLingui() const moderationOpts = useModerationOpts() const navigation = useNavigation<NavigationProp>() const {gtMobile} = useBreakpoints() |