feat: Add relationship info to hover card (#34792)
This commit is contained in:
parent
c025824f98
commit
975db93e3f
2 changed files with 31 additions and 2 deletions
|
@ -45,6 +45,19 @@ export const HoverCardAccount = forwardRef<
|
||||||
|
|
||||||
const { familiarFollowers } = useFetchFamiliarFollowers({ accountId });
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
@ -85,7 +98,7 @@ export const HoverCardAccount = forwardRef<
|
||||||
value={account.followers_count}
|
value={account.followers_count}
|
||||||
renderer={FollowersCounter}
|
renderer={FollowersCounter}
|
||||||
/>
|
/>
|
||||||
{familiarFollowers.length > 0 && (
|
{shouldDisplayFamiliarFollowers && (
|
||||||
<>
|
<>
|
||||||
·
|
·
|
||||||
<div className='hover-card__familiar-followers'>
|
<div className='hover-card__familiar-followers'>
|
||||||
|
@ -101,6 +114,22 @@ export const HoverCardAccount = forwardRef<
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{(isMutual || isFollower) && (
|
||||||
|
<>
|
||||||
|
·
|
||||||
|
{isMutual ? (
|
||||||
|
<FormattedMessage
|
||||||
|
id='account.mutual'
|
||||||
|
defaultMessage='You follow each other'
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<FormattedMessage
|
||||||
|
id='account.follows_you'
|
||||||
|
defaultMessage='Follows you'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<FollowButton accountId={accountId} />
|
<FollowButton accountId={accountId} />
|
||||||
|
|
|
@ -10766,7 +10766,7 @@ noscript {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 10px;
|
gap: 2px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__numbers {
|
&__numbers {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue