From ad71585298d88a13795c687bc76ef9a2d845d3a0 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 7 Jan 2025 17:13:28 -0600 Subject: [PATCH] Update new ProfileCard to use AnyProfileView --- src/components/ProfileCard.tsx | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/ProfileCard.tsx b/src/components/ProfileCard.tsx index 7bec14b9cc..5b1a72fafa 100644 --- a/src/components/ProfileCard.tsx +++ b/src/components/ProfileCard.tsx @@ -1,7 +1,6 @@ import React from 'react' import {GestureResponderEvent, View} from 'react-native' import { - AppBskyActorDefs, moderateProfile, ModerationOpts, RichText as RichTextApi, @@ -25,13 +24,14 @@ import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus import {Link as InternalLink, LinkProps} from '#/components/Link' import {RichText} from '#/components/RichText' import {Text} from '#/components/Typography' +import * as atp from '#/types/atproto' export function Default({ profile, moderationOpts, logContext = 'ProfileCard', }: { - profile: AppBskyActorDefs.ProfileViewDetailed + profile: atp.profile.AnyProfileView moderationOpts: ModerationOpts logContext?: 'ProfileCard' | 'StarterPackProfilesList' }) { @@ -51,7 +51,7 @@ export function Card({ moderationOpts, logContext = 'ProfileCard', }: { - profile: AppBskyActorDefs.ProfileViewDetailed + profile: atp.profile.AnyProfileView moderationOpts: ModerationOpts logContext?: 'ProfileCard' | 'StarterPackProfilesList' }) { @@ -101,7 +101,7 @@ export function Link({ style, ...rest }: { - profile: AppBskyActorDefs.ProfileViewDetailed + profile: atp.profile.AnyProfileView } & Omit) { const {_} = useLingui() return ( @@ -126,7 +126,7 @@ export function Avatar({ profile, moderationOpts, }: { - profile: AppBskyActorDefs.ProfileViewDetailed + profile: atp.profile.AnyProfileView moderationOpts: ModerationOpts }) { const moderation = moderateProfile(profile, moderationOpts) @@ -161,7 +161,7 @@ export function NameAndHandle({ profile, moderationOpts, }: { - profile: AppBskyActorDefs.ProfileViewDetailed + profile: atp.profile.AnyProfileView moderationOpts: ModerationOpts }) { const t = useTheme() @@ -224,17 +224,16 @@ export function Description({ profile: profileUnshadowed, numberOfLines = 3, }: { - profile: AppBskyActorDefs.ProfileViewDetailed + profile: atp.profile.AnyProfileView numberOfLines?: number }) { const profile = useProfileShadow(profileUnshadowed) - const {description} = profile const rt = React.useMemo(() => { - if (!description) return - const rt = new RichTextApi({text: description || ''}) + if (!('description' in profile)) return + const rt = new RichTextApi({text: profile.description || ''}) rt.detectFacetsWithoutResolution() return rt - }, [description]) + }, [profile]) if (!rt) return null if ( profile.viewer && @@ -281,7 +280,7 @@ export function DescriptionPlaceholder({ } export type FollowButtonProps = { - profile: AppBskyActorDefs.ProfileViewBasic + profile: atp.profile.AnyProfileView moderationOpts: ModerationOpts logContext: LogEvents['profile:follow']['logContext'] & LogEvents['profile:unfollow']['logContext']