import { useEffect, forwardRef } from 'react'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { Link } from 'react-router-dom'; import { fetchAccount } from 'mastodon/actions/accounts'; import { AccountBio } from 'mastodon/components/account_bio'; import { AccountFields } from 'mastodon/components/account_fields'; import { Avatar } from 'mastodon/components/avatar'; import { AvatarGroup } from 'mastodon/components/avatar_group'; import { FollowersCounter, FollowersYouKnowCounter, } from 'mastodon/components/counters'; import { DisplayName } from 'mastodon/components/display_name'; import { FollowButton } from 'mastodon/components/follow_button'; import { LoadingIndicator } from 'mastodon/components/loading_indicator'; import { ShortNumber } from 'mastodon/components/short_number'; import { useFetchFamiliarFollowers } from 'mastodon/features/account_timeline/hooks/familiar_followers'; import { domain } from 'mastodon/initial_state'; import { useAppSelector, useAppDispatch } from 'mastodon/store'; export const HoverCardAccount = forwardRef< HTMLDivElement, { accountId?: string } >(({ accountId }, ref) => { const dispatch = useAppDispatch(); const account = useAppSelector((state) => accountId ? state.accounts.get(accountId) : undefined, ); const note = useAppSelector( (state) => state.relationships.getIn([accountId, 'note']) as string | undefined, ); useEffect(() => { if (accountId && !account) { dispatch(fetchAccount(accountId)); } }, [dispatch, accountId, account]); 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 ( ); }); HoverCardAccount.displayName = 'HoverCardAccount';