diff options
Diffstat (limited to 'src/view/com/modals/ProfilePreview.tsx')
-rw-r--r-- | src/view/com/modals/ProfilePreview.tsx | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/src/view/com/modals/ProfilePreview.tsx b/src/view/com/modals/ProfilePreview.tsx deleted file mode 100644 index 1764b6b90..000000000 --- a/src/view/com/modals/ProfilePreview.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import React, {useState, useEffect} from 'react' -import {ActivityIndicator, StyleSheet, View} from 'react-native' -import {AppBskyActorDefs, ModerationOpts, moderateProfile} from '@atproto/api' -import {ThemedText} from '../util/text/ThemedText' -import {usePalette} from 'lib/hooks/usePalette' -import {useAnalytics} from 'lib/analytics/analytics' -import {ProfileHeader} from '../profile/ProfileHeader' -import {InfoCircleIcon} from 'lib/icons' -import {useNavigationState} from '@react-navigation/native' -import {s} from 'lib/styles' -import {useModerationOpts} from '#/state/queries/preferences' -import {useProfileQuery} from '#/state/queries/profile' -import {ErrorScreen} from '../util/error/ErrorScreen' -import {CenteredView} from '../util/Views' -import {cleanError} from '#/lib/strings/errors' -import {useProfileShadow} from '#/state/cache/profile-shadow' -import {Trans, msg} from '@lingui/macro' -import {useLingui} from '@lingui/react' - -export const snapPoints = [520, '100%'] - -export function Component({did}: {did: string}) { - const pal = usePalette('default') - const {_} = useLingui() - const moderationOpts = useModerationOpts() - const { - data: profile, - error: profileError, - refetch: refetchProfile, - isLoading: isLoadingProfile, - } = useProfileQuery({ - did: did, - }) - - if (isLoadingProfile || !moderationOpts) { - return ( - <CenteredView style={[pal.view, s.flex1]}> - <ProfileHeader - profile={null} - moderation={null} - isProfilePreview={true} - /> - </CenteredView> - ) - } - if (profileError) { - return ( - <ErrorScreen - title={_(msg`Not Found`)} - message={cleanError(profileError)} - onPressTryAgain={refetchProfile} - /> - ) - } - if (profile && moderationOpts) { - return <ComponentLoaded profile={profile} moderationOpts={moderationOpts} /> - } - // should never happen - return ( - <ErrorScreen - title={_(msg`Oops!`)} - message={_(msg`Something went wrong and we're not sure what.`)} - onPressTryAgain={refetchProfile} - /> - ) -} - -function ComponentLoaded({ - profile: profileUnshadowed, - moderationOpts, -}: { - profile: AppBskyActorDefs.ProfileViewDetailed - moderationOpts: ModerationOpts -}) { - const pal = usePalette('default') - const profile = useProfileShadow(profileUnshadowed) - const {screen} = useAnalytics() - const moderation = React.useMemo( - () => moderateProfile(profile, moderationOpts), - [profile, moderationOpts], - ) - - // track the navigator state to detect if a page-load occurred - const navState = useNavigationState(state => state) - const [initNavState] = useState(navState) - const isLoading = initNavState !== navState - - useEffect(() => { - screen('Profile:Preview') - }, [screen]) - - return ( - <View testID="profilePreview" style={[pal.view, s.flex1]}> - <View style={[styles.headerWrapper]}> - <ProfileHeader - profile={profile} - moderation={moderation} - hideBackButton - isProfilePreview - /> - </View> - <View style={[styles.hintWrapper, pal.view]}> - <View style={styles.hint}> - {isLoading ? ( - <ActivityIndicator /> - ) : ( - <> - <InfoCircleIcon size={21} style={pal.textLight} /> - <ThemedText type="xl" fg="light"> - <Trans>Swipe up to see more</Trans> - </ThemedText> - </> - )} - </View> - </View> - </View> - ) -} - -const styles = StyleSheet.create({ - headerWrapper: { - height: 440, - }, - hintWrapper: { - height: 80, - }, - hint: { - flexDirection: 'row', - justifyContent: 'center', - gap: 8, - paddingHorizontal: 14, - borderRadius: 6, - }, -}) |