forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {View} from 'react-native'
2import {Trans} from '@lingui/macro'
3
4import {useSession} from '#/state/session'
5import {UserInfoText} from '#/view/com/util/UserInfoText'
6import {atoms as a, useTheme} from '#/alf'
7import {ArrowCornerDownRight_Stroke2_Corner2_Rounded as ArrowCornerDownRightIcon} from '#/components/icons/ArrowCornerDownRight'
8import {ProfileHoverCard} from '#/components/ProfileHoverCard'
9import {Text} from '#/components/Typography'
10import type * as bsky from '#/types/bsky'
11
12export function PostRepliedTo({
13 parentAuthor,
14 isParentBlocked,
15 isParentNotFound,
16}: {
17 parentAuthor: string | bsky.profile.AnyProfileView | undefined
18 isParentBlocked?: boolean
19 isParentNotFound?: boolean
20}) {
21 const t = useTheme()
22 const {currentAccount} = useSession()
23
24 const textStyle = [a.text_sm, t.atoms.text_contrast_medium, a.leading_snug]
25
26 let label
27 if (isParentBlocked) {
28 label = <Trans context="description">Replied to a blocked post</Trans>
29 } else if (isParentNotFound) {
30 label = <Trans context="description">Replied to a post</Trans>
31 } else if (parentAuthor) {
32 const did =
33 typeof parentAuthor === 'string' ? parentAuthor : parentAuthor.did
34 const isMe = currentAccount?.did === did
35 if (isMe) {
36 label = <Trans context="description">Replied to you</Trans>
37 } else {
38 label = (
39 <Trans context="description">
40 Replied to{' '}
41 <ProfileHoverCard did={did}>
42 <UserInfoText did={did} attr="displayName" style={textStyle} />
43 </ProfileHoverCard>
44 </Trans>
45 )
46 }
47 }
48
49 if (!label) {
50 // Should not happen.
51 return null
52 }
53
54 return (
55 <View style={[a.flex_row, a.align_center, a.pb_xs, a.gap_xs]}>
56 <ArrowCornerDownRightIcon
57 size="xs"
58 style={[t.atoms.text_contrast_medium, {top: -1}]}
59 />
60 <Text style={[a.flex_1, textStyle]} numberOfLines={1}>
61 {label}
62 </Text>
63 </View>
64 )
65}