import { useCallback } from 'react'; import type { FC, ReactElement, ReactNode } from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import { authorizeFollowRequest, rejectFollowRequest, } from '@/mastodon/actions/accounts'; import { useAccountVisibility } from '@/mastodon/hooks/useAccountVisibility'; import { useRelationship } from '@/mastodon/hooks/useRelationship'; import type { Account } from '@/mastodon/models/account'; import { useAppDispatch, useAppSelector } from '@/mastodon/store'; import CheckIcon from '@/material-icons/400-24px/check.svg?react'; import CloseIcon from '@/material-icons/400-24px/close.svg?react'; import { AvatarOverlay } from '../avatar_overlay'; import { Button } from '../button'; import { DisplayName } from '../display_name'; import { Icon } from '../icon'; import classes from './styles.module.scss'; export const AccountBanners: FC<{ account: Account }> = ({ account }) => { const { suspended, hidden } = useAccountVisibility(account.id); const relationship = useRelationship(account.id); if (hidden) { return null; } let banner: ReactNode = null; if (account.memorial) { banner = ( ); } if (account.moved) { banner = ; } if (!suspended && relationship?.requested_by) { banner = ; } if (!banner) { return null; } return
{banner}
; }; const FollowRequestNote: FC<{ account: Account }> = ({ account }) => { const accountId = account.id; const dispatch = useAppDispatch(); const handleAuthorize = useCallback(() => { dispatch(authorizeFollowRequest(accountId)); }, [accountId, dispatch]); const handleReject = useCallback(() => { dispatch(rejectFollowRequest(accountId)); }, [accountId, dispatch]); return ( <> }} />
); }; const MovedNote: React.FC<{ account: Account; targetAccountId: string; }> = ({ account: from, targetAccountId }) => { const to = useAppSelector((state) => state.accounts.get(targetAccountId)); return ( <> , }} />
); }; const MessageText: React.FC<{ children: ReactElement }> = ({ children }) => (
{children}
);