feat: Add relationship info to hover card (#34792)

This commit is contained in:
diondiondion 2025-05-30 14:32:19 +02:00 committed by GitHub
parent c025824f98
commit 975db93e3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 2 deletions

View file

@ -45,6 +45,19 @@ export const HoverCardAccount = forwardRef<
const { familiarFollowers } = useFetchFamiliarFollowers({ accountId });
const relationship = useAppSelector((state) =>
accountId ? state.relationships.get(accountId) : undefined,
);
const isMutual = relationship?.followed_by && relationship.following;
const isFollower = relationship?.followed_by;
const hasRelationshipLoaded = !!relationship;
const shouldDisplayFamiliarFollowers =
familiarFollowers.length > 0 &&
hasRelationshipLoaded &&
!isMutual &&
!isFollower;
return (
<div
ref={ref}
@ -85,7 +98,7 @@ export const HoverCardAccount = forwardRef<
value={account.followers_count}
renderer={FollowersCounter}
/>
{familiarFollowers.length > 0 && (
{shouldDisplayFamiliarFollowers && (
<>
&middot;
<div className='hover-card__familiar-followers'>
@ -101,6 +114,22 @@ export const HoverCardAccount = forwardRef<
</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} />

View file

@ -10766,7 +10766,7 @@ noscript {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
gap: 2px 10px;
}
&__numbers {