Update new ProfileCard to use AnyProfileView

This commit is contained in:
Eric Bailey
2025-01-07 17:13:28 -06:00
parent 9449edf07a
commit ad71585298
+11 -12
View File
@@ -1,7 +1,6 @@
import React from 'react' import React from 'react'
import {GestureResponderEvent, View} from 'react-native' import {GestureResponderEvent, View} from 'react-native'
import { import {
AppBskyActorDefs,
moderateProfile, moderateProfile,
ModerationOpts, ModerationOpts,
RichText as RichTextApi, 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 {Link as InternalLink, LinkProps} from '#/components/Link'
import {RichText} from '#/components/RichText' import {RichText} from '#/components/RichText'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import * as atp from '#/types/atproto'
export function Default({ export function Default({
profile, profile,
moderationOpts, moderationOpts,
logContext = 'ProfileCard', logContext = 'ProfileCard',
}: { }: {
profile: AppBskyActorDefs.ProfileViewDetailed profile: atp.profile.AnyProfileView
moderationOpts: ModerationOpts moderationOpts: ModerationOpts
logContext?: 'ProfileCard' | 'StarterPackProfilesList' logContext?: 'ProfileCard' | 'StarterPackProfilesList'
}) { }) {
@@ -51,7 +51,7 @@ export function Card({
moderationOpts, moderationOpts,
logContext = 'ProfileCard', logContext = 'ProfileCard',
}: { }: {
profile: AppBskyActorDefs.ProfileViewDetailed profile: atp.profile.AnyProfileView
moderationOpts: ModerationOpts moderationOpts: ModerationOpts
logContext?: 'ProfileCard' | 'StarterPackProfilesList' logContext?: 'ProfileCard' | 'StarterPackProfilesList'
}) { }) {
@@ -101,7 +101,7 @@ export function Link({
style, style,
...rest ...rest
}: { }: {
profile: AppBskyActorDefs.ProfileViewDetailed profile: atp.profile.AnyProfileView
} & Omit<LinkProps, 'to' | 'label'>) { } & Omit<LinkProps, 'to' | 'label'>) {
const {_} = useLingui() const {_} = useLingui()
return ( return (
@@ -126,7 +126,7 @@ export function Avatar({
profile, profile,
moderationOpts, moderationOpts,
}: { }: {
profile: AppBskyActorDefs.ProfileViewDetailed profile: atp.profile.AnyProfileView
moderationOpts: ModerationOpts moderationOpts: ModerationOpts
}) { }) {
const moderation = moderateProfile(profile, moderationOpts) const moderation = moderateProfile(profile, moderationOpts)
@@ -161,7 +161,7 @@ export function NameAndHandle({
profile, profile,
moderationOpts, moderationOpts,
}: { }: {
profile: AppBskyActorDefs.ProfileViewDetailed profile: atp.profile.AnyProfileView
moderationOpts: ModerationOpts moderationOpts: ModerationOpts
}) { }) {
const t = useTheme() const t = useTheme()
@@ -224,17 +224,16 @@ export function Description({
profile: profileUnshadowed, profile: profileUnshadowed,
numberOfLines = 3, numberOfLines = 3,
}: { }: {
profile: AppBskyActorDefs.ProfileViewDetailed profile: atp.profile.AnyProfileView
numberOfLines?: number numberOfLines?: number
}) { }) {
const profile = useProfileShadow(profileUnshadowed) const profile = useProfileShadow(profileUnshadowed)
const {description} = profile
const rt = React.useMemo(() => { const rt = React.useMemo(() => {
if (!description) return if (!('description' in profile)) return
const rt = new RichTextApi({text: description || ''}) const rt = new RichTextApi({text: profile.description || ''})
rt.detectFacetsWithoutResolution() rt.detectFacetsWithoutResolution()
return rt return rt
}, [description]) }, [profile])
if (!rt) return null if (!rt) return null
if ( if (
profile.viewer && profile.viewer &&
@@ -281,7 +280,7 @@ export function DescriptionPlaceholder({
} }
export type FollowButtonProps = { export type FollowButtonProps = {
profile: AppBskyActorDefs.ProfileViewBasic profile: atp.profile.AnyProfileView
moderationOpts: ModerationOpts moderationOpts: ModerationOpts
logContext: LogEvents['profile:follow']['logContext'] & logContext: LogEvents['profile:follow']['logContext'] &
LogEvents['profile:unfollow']['logContext'] LogEvents['profile:unfollow']['logContext']