`Reposted by you` and `Reply to you` (#4478)

Co-authored-by: Hailey <me@haileyok.com>
zio/stable
Minseo Lee 2024-07-12 11:42:27 +09:00 committed by GitHub
parent 8b121af2e4
commit a71134f467
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 62 additions and 35 deletions

View File

@ -15,6 +15,7 @@ import {useQueryClient} from '@tanstack/react-query'
import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped'
import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow' import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow'
import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useSession} from '#/state/session'
import {useComposerControls} from '#/state/shell/composer' import {useComposerControls} from '#/state/shell/composer'
import {MAX_POST_LINES} from 'lib/constants' import {MAX_POST_LINES} from 'lib/constants'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
@ -145,6 +146,9 @@ function PostInner({
precacheProfile(queryClient, post.author) precacheProfile(queryClient, post.author)
}, [queryClient, post.author]) }, [queryClient, post.author])
const {currentAccount} = useSession()
const isMe = replyAuthorDid === currentAccount?.did
return ( return (
<Link <Link
href={itemHref} href={itemHref}
@ -187,17 +191,21 @@ function PostInner({
style={[pal.textLight, s.mr2]} style={[pal.textLight, s.mr2]}
lineHeight={1.2} lineHeight={1.2}
numberOfLines={1}> numberOfLines={1}>
<Trans context="description"> {isMe ? (
Reply to{' '} <Trans context="description">Reply to you</Trans>
<ProfileHoverCard inline did={replyAuthorDid}> ) : (
<UserInfoText <Trans context="description">
type="sm" Reply to{' '}
did={replyAuthorDid} <ProfileHoverCard inline did={replyAuthorDid}>
attr="displayName" <UserInfoText
style={[pal.textLight]} type="sm"
/> did={replyAuthorDid}
</ProfileHoverCard> attr="displayName"
</Trans> style={[pal.textLight]}
/>
</ProfileHoverCard>
</Trans>
)}
</Text> </Text>
</View> </View>
)} )}

View File

@ -43,6 +43,7 @@ import {Text} from '../util/text/Text'
import {PreviewableUserAvatar} from '../util/UserAvatar' import {PreviewableUserAvatar} from '../util/UserAvatar'
import {AviFollowButton} from './AviFollowButton' import {AviFollowButton} from './AviFollowButton'
import hairlineWidth = StyleSheet.hairlineWidth import hairlineWidth = StyleSheet.hairlineWidth
import {useSession} from '#/state/session'
import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost' import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost'
interface FeedItemProps { interface FeedItemProps {
@ -200,6 +201,11 @@ let FeedItemInner = ({
}, },
] ]
const {currentAccount} = useSession()
const isOwner =
AppBskyFeedDefs.isReasonRepost(reason) &&
reason.by.did === currentAccount?.did
return ( return (
<Link <Link
testID={`feedItem-by-${post.author.handle}`} testID={`feedItem-by-${post.author.handle}`}
@ -250,11 +256,15 @@ let FeedItemInner = ({
<Link <Link
style={styles.includeReason} style={styles.includeReason}
href={makeProfileLink(reason.by)} href={makeProfileLink(reason.by)}
title={_( title={
msg`Reposted by ${sanitizeDisplayName( isOwner
reason.by.displayName || reason.by.handle, ? _(msg`Reposted by you`)
)}`, : _(
)} msg`Reposted by ${sanitizeDisplayName(
reason.by.displayName || reason.by.handle,
)}`,
)
}
onBeforePress={onOpenReposter}> onBeforePress={onOpenReposter}>
<Repost <Repost
style={{color: pal.colors.textLight, marginRight: 3}} style={{color: pal.colors.textLight, marginRight: 3}}
@ -266,24 +276,28 @@ let FeedItemInner = ({
style={pal.textLight} style={pal.textLight}
lineHeight={1.2} lineHeight={1.2}
numberOfLines={1}> numberOfLines={1}>
<Trans> {isOwner ? (
Reposted by{' '} <Trans>Reposted by you</Trans>
<ProfileHoverCard inline did={reason.by.did}> ) : (
<TextLinkOnWebOnly <Trans>
type="sm-bold" Reposted by{' '}
style={pal.textLight} <ProfileHoverCard inline did={reason.by.did}>
lineHeight={1.2} <TextLinkOnWebOnly
numberOfLines={1} type="sm-bold"
text={sanitizeDisplayName( style={pal.textLight}
reason.by.displayName || lineHeight={1.2}
sanitizeHandle(reason.by.handle), numberOfLines={1}
moderation.ui('displayName'), text={sanitizeDisplayName(
)} reason.by.displayName ||
href={makeProfileLink(reason.by)} sanitizeHandle(reason.by.handle),
onBeforePress={onOpenReposter} moderation.ui('displayName'),
/> )}
</ProfileHoverCard> href={makeProfileLink(reason.by)}
</Trans> onBeforePress={onOpenReposter}
/>
</ProfileHoverCard>
</Trans>
)}
</Text> </Text>
</Link> </Link>
) : null} ) : null}
@ -421,6 +435,9 @@ function ReplyToLabel({
blocked?: boolean blocked?: boolean
}) { }) {
const pal = usePalette('default') const pal = usePalette('default')
const {currentAccount} = useSession()
const isMe = profile.did === currentAccount?.did
return ( return (
<View style={[s.flexRow, s.mb2, s.alignCenter]}> <View style={[s.flexRow, s.mb2, s.alignCenter]}>
<FontAwesomeIcon <FontAwesomeIcon
@ -433,7 +450,9 @@ function ReplyToLabel({
style={[pal.textLight, s.mr2]} style={[pal.textLight, s.mr2]}
lineHeight={1.2} lineHeight={1.2}
numberOfLines={1}> numberOfLines={1}>
{blocked ? ( {isMe ? (
<Trans context="description">Reply to you</Trans>
) : blocked ? (
<Trans context="description">Reply to a blocked post</Trans> <Trans context="description">Reply to a blocked post</Trans>
) : ( ) : (
<Trans context="description"> <Trans context="description">