diff options
author | Kuwa Lee <kuwalee1069@gmail.com> | 2024-06-13 15:29:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 15:29:51 +0800 |
commit | ecd51bc6f9f7d755eb023c3d336c21ea5b1583e5 (patch) | |
tree | 0079550833142d4842a6e7bcff4d1540bad18870 /src/components/ProfileHoverCard/index.web.tsx | |
parent | bd8f0e5a1c3a49b3f134081475f90473b87111b1 (diff) | |
parent | 7faa1d9131fc28e1c0acd4b4c7b7c2bbeabc2281 (diff) | |
download | voidsky-ecd51bc6f9f7d755eb023c3d336c21ea5b1583e5.tar.zst |
Merge branch 'bluesky-social:main' into zh
Diffstat (limited to 'src/components/ProfileHoverCard/index.web.tsx')
-rw-r--r-- | src/components/ProfileHoverCard/index.web.tsx | 94 |
1 files changed, 69 insertions, 25 deletions
diff --git a/src/components/ProfileHoverCard/index.web.tsx b/src/components/ProfileHoverCard/index.web.tsx index 024867b1a..e17977af4 100644 --- a/src/components/ProfileHoverCard/index.web.tsx +++ b/src/components/ProfileHoverCard/index.web.tsx @@ -5,6 +5,7 @@ import {flip, offset, shift, size, useFloating} from '@floating-ui/react-dom' import {msg, plural} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {getModerationCauseKey} from '#/lib/moderation' import {makeProfileLink} from '#/lib/routes/links' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeHandle} from '#/lib/strings/handles' @@ -22,11 +23,16 @@ import {useFollowMethods} from '#/components/hooks/useFollowMethods' import {useRichText} from '#/components/hooks/useRichText' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' +import { + KnownFollowers, + shouldShowKnownFollowers, +} from '#/components/KnownFollowers' import {InlineLinkText, Link} from '#/components/Link' import {Loader} from '#/components/Loader' import {Portal} from '#/components/Portal' import {RichText} from '#/components/RichText' import {Text} from '#/components/Typography' +import {ProfileLabel} from '../moderation/ProfileHeaderAlerts' import {ProfileHoverCardProps} from './types' const floatingMiddlewares = [ @@ -370,7 +376,10 @@ function Inner({ profile: profileShadow, logContext: 'ProfileHoverCard', }) - const blockHide = profile.viewer?.blocking || profile.viewer?.blockedBy + const isBlockedUser = + profile.viewer?.blocking || + profile.viewer?.blockedBy || + profile.viewer?.blockingByList const following = formatCount(profile.followsCount || 0) const followers = formatCount(profile.followersCount || 0) const pluralizedFollowers = plural(profile.followersCount || 0, { @@ -401,29 +410,41 @@ function Inner({ /> </Link> - {!isMe && ( - <Button - size="small" - color={profileShadow.viewer?.following ? 'secondary' : 'primary'} - variant="solid" - label={ - profileShadow.viewer?.following - ? _(msg`Following`) - : _(msg`Follow`) - } - style={[a.rounded_full]} - onPress={profileShadow.viewer?.following ? unfollow : follow}> - <ButtonIcon - position="left" - icon={profileShadow.viewer?.following ? Check : Plus} - /> - <ButtonText> - {profileShadow.viewer?.following - ? _(msg`Following`) - : _(msg`Follow`)} - </ButtonText> - </Button> - )} + {!isMe && + (isBlockedUser ? ( + <Link + to={profileURL} + label={_(msg`View blocked user's profile`)} + onPress={hide} + size="small" + color="secondary" + variant="solid" + style={[a.rounded_full]}> + <ButtonText>{_(msg`View profile`)}</ButtonText> + </Link> + ) : ( + <Button + size="small" + color={profileShadow.viewer?.following ? 'secondary' : 'primary'} + variant="solid" + label={ + profileShadow.viewer?.following + ? _(msg`Following`) + : _(msg`Follow`) + } + style={[a.rounded_full]} + onPress={profileShadow.viewer?.following ? unfollow : follow}> + <ButtonIcon + position="left" + icon={profileShadow.viewer?.following ? Check : Plus} + /> + <ButtonText> + {profileShadow.viewer?.following + ? _(msg`Following`) + : _(msg`Follow`)} + </ButtonText> + </Button> + ))} </View> <Link to={profileURL} label={_(msg`View profile`)} onPress={hide}> @@ -439,7 +460,19 @@ function Inner({ </View> </Link> - {!blockHide && ( + {isBlockedUser && ( + <View style={[a.flex_row, a.flex_wrap, a.gap_xs]}> + {moderation.ui('profileView').alerts.map(cause => ( + <ProfileLabel + key={getModerationCauseKey(cause)} + cause={cause} + disableDetailsDialog + /> + ))} + </View> + )} + + {!isBlockedUser && ( <> <View style={[a.flex_row, a.flex_wrap, a.gap_md, a.pt_xs]}> <InlineLinkText @@ -473,6 +506,17 @@ function Inner({ /> </View> ) : undefined} + + {!isMe && + shouldShowKnownFollowers(profile.viewer?.knownFollowers) && ( + <View style={[a.flex_row, a.align_center, a.gap_sm, a.pt_md]}> + <KnownFollowers + profile={profile} + moderationOpts={moderationOpts} + onLinkPress={hide} + /> + </View> + )} </> )} </View> |