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 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 && (
|
||||
<>
|
||||
·
|
||||
<div className='hover-card__familiar-followers'>
|
||||
|
@ -101,6 +114,22 @@ export const HoverCardAccount = forwardRef<
|
|||
</div>
|
||||
</>
|
||||
)}
|
||||
{(isMutual || isFollower) && (
|
||||
<>
|
||||
·
|
||||
{isMutual ? (
|
||||
<FormattedMessage
|
||||
id='account.mutual'
|
||||
defaultMessage='You follow each other'
|
||||
/>
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id='account.follows_you'
|
||||
defaultMessage='Follows you'
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<FollowButton accountId={accountId} />
|
||||
|
|
|
@ -10766,7 +10766,7 @@ noscript {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
gap: 2px 10px;
|
||||
}
|
||||
|
||||
&__numbers {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue