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

This commit is contained in:
diondiondion authored and GitHub committed 2025-05-30 12:32:19 +00:00
1 parent c025824f98
commit 975db93e3f
2 files changed
+31 -2

No files matched your search

@@ -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} />