fix: Hide limited user info in hover card (#35024)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions

This commit is contained in:
diondiondion 2025-06-12 18:13:17 +02:00 committed by GitHub
parent 319fbbbfac
commit f92ff6d699
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 95 additions and 58 deletions

View File

@ -20,6 +20,7 @@ import { LoadingIndicator } from 'mastodon/components/loading_indicator';
import { ShortNumber } from 'mastodon/components/short_number'; import { ShortNumber } from 'mastodon/components/short_number';
import { useFetchFamiliarFollowers } from 'mastodon/features/account_timeline/hooks/familiar_followers'; import { useFetchFamiliarFollowers } from 'mastodon/features/account_timeline/hooks/familiar_followers';
import { domain } from 'mastodon/initial_state'; import { domain } from 'mastodon/initial_state';
import { getAccountHidden } from 'mastodon/selectors/accounts';
import { useAppSelector, useAppDispatch } from 'mastodon/store'; import { useAppSelector, useAppDispatch } from 'mastodon/store';
export const HoverCardAccount = forwardRef< export const HoverCardAccount = forwardRef<
@ -31,6 +32,11 @@ export const HoverCardAccount = forwardRef<
const account = useAppSelector((state) => const account = useAppSelector((state) =>
accountId ? state.accounts.get(accountId) : undefined, accountId ? state.accounts.get(accountId) : undefined,
); );
const suspended = account?.suspended;
const hidden = useAppSelector((state) =>
accountId ? getAccountHidden(state, accountId) : undefined,
);
const isSuspendedOrHidden = Boolean(suspended || hidden);
const note = useAppSelector( const note = useAppSelector(
(state) => (state) =>
@ -70,69 +76,95 @@ export const HoverCardAccount = forwardRef<
{account ? ( {account ? (
<> <>
<Link to={`/@${account.acct}`} className='hover-card__name'> <Link to={`/@${account.acct}`} className='hover-card__name'>
<Avatar account={account} size={46} /> <Avatar
account={isSuspendedOrHidden ? undefined : account}
size={46}
/>
<DisplayName account={account} localDomain={domain} /> <DisplayName account={account} localDomain={domain} />
</Link> </Link>
<div className='hover-card__text-row'> {isSuspendedOrHidden ? (
<AccountBio <div className='hover-card__limited-account-note'>
note={account.note_emojified} {suspended ? (
className='hover-card__bio' <FormattedMessage
/> id='empty_column.account_suspended'
<AccountFields fields={account.fields} limit={2} /> defaultMessage='Account suspended'
{note && note.length > 0 && ( />
<dl className='hover-card__note'> ) : (
<dt className='hover-card__note-label'> <FormattedMessage
<FormattedMessage id='limited_account_hint.title'
id='account.account_note_header' defaultMessage='This profile has been hidden by the moderators of {domain}.'
defaultMessage='Personal note' values={{ domain }}
/> />
</dt> )}
<dd>{note}</dd> </div>
</dl> ) : (
)} <>
</div> <div className='hover-card__text-row'>
<AccountBio
<div className='hover-card__numbers'> note={account.note_emojified}
<ShortNumber className='hover-card__bio'
value={account.followers_count} />
renderer={FollowersCounter} <AccountFields fields={account.fields} limit={2} />
/> {note && note.length > 0 && (
{shouldDisplayFamiliarFollowers && ( <dl className='hover-card__note'>
<> <dt className='hover-card__note-label'>
&middot; <FormattedMessage
<div className='hover-card__familiar-followers'> id='account.account_note_header'
<ShortNumber defaultMessage='Personal note'
value={familiarFollowers.length} />
renderer={FollowersYouKnowCounter} </dt>
/> <dd>{note}</dd>
<AvatarGroup compact> </dl>
{familiarFollowers.slice(0, 3).map((account) => (
<Avatar key={account.id} account={account} size={22} />
))}
</AvatarGroup>
</div>
</>
)}
{(isMutual || isFollower) && (
<>
&middot;
{isMutual ? (
<FormattedMessage
id='account.mutual'
defaultMessage='You follow each other'
/>
) : (
<FormattedMessage
id='account.follows_you'
defaultMessage='Follows you'
/>
)} )}
</> </div>
)}
</div>
<FollowButton accountId={accountId} /> <div className='hover-card__numbers'>
<ShortNumber
value={account.followers_count}
renderer={FollowersCounter}
/>
{shouldDisplayFamiliarFollowers && (
<>
&middot;
<div className='hover-card__familiar-followers'>
<ShortNumber
value={familiarFollowers.length}
renderer={FollowersYouKnowCounter}
/>
<AvatarGroup compact>
{familiarFollowers.slice(0, 3).map((account) => (
<Avatar
key={account.id}
account={account}
size={22}
/>
))}
</AvatarGroup>
</div>
</>
)}
{(isMutual || isFollower) && (
<>
&middot;
{isMutual ? (
<FormattedMessage
id='account.mutual'
defaultMessage='You follow each other'
/>
) : (
<FormattedMessage
id='account.follows_you'
defaultMessage='Follows you'
/>
)}
</>
)}
</div>
<FollowButton accountId={accountId} />
</>
)}
</> </>
) : ( ) : (
<LoadingIndicator /> <LoadingIndicator />

View File

@ -10899,6 +10899,11 @@ noscript {
} }
} }
&__limited-account-note {
text-align: center;
font-weight: 500;
}
.display-name { .display-name {
font-size: 15px; font-size: 15px;
line-height: 22px; line-height: 22px;