import { useEffect } from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import { fetchAccountsFamiliarFollowers } from '@/mastodon/actions/accounts_familiar_followers'; import { Avatar } from '@/mastodon/components/avatar'; import { AvatarGroup } from '@/mastodon/components/avatar_group'; import type { Account } from '@/mastodon/models/account'; import { getAccountFamiliarFollowers } from '@/mastodon/selectors/accounts'; import { useAppDispatch, useAppSelector } from '@/mastodon/store'; const AccountLink: React.FC<{ account?: Account }> = ({ account }) => { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const name = account?.display_name || `@${account?.acct}`; return ( {name} ); }; const FamiliarFollowersReadout: React.FC<{ familiarFollowers: Account[] }> = ({ familiarFollowers, }) => { const messageData = { name1: , name2: , othersCount: familiarFollowers.length - 2, }; if (familiarFollowers.length === 1) { return ( ); } else if (familiarFollowers.length === 2) { return ( ); } else { return ( ); } }; export const FamiliarFollowers: React.FC<{ accountId: string }> = ({ accountId, }) => { const dispatch = useAppDispatch(); const familiarFollowers = useAppSelector((state) => getAccountFamiliarFollowers(state, accountId), ); const hasNoData = familiarFollowers === null; useEffect(() => { if (hasNoData) { void dispatch(fetchAccountsFamiliarFollowers({ id: accountId })); } }, [dispatch, accountId, hasNoData]); if (hasNoData || familiarFollowers.length === 0) { return null; } return (
{familiarFollowers.map((account) => ( ))}
); };