import { useCallback } from 'react'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import { openModal } from '@/mastodon/actions/modal'; import { Button } from '@/mastodon/components/button'; import { DisplayName } from '@/mastodon/components/display_name'; import { EmptyState } from '@/mastodon/components/empty_state'; import { LimitedAccountHint } from '@/mastodon/components/limited_account_hint'; import { areCollectionsEnabled } from '@/mastodon/features/collections/utils'; import { useAccount } from '@/mastodon/hooks/useAccount'; import { useCurrentAccountId } from '@/mastodon/hooks/useAccountId'; import { useAppDispatch } from '@/mastodon/store'; interface EmptyMessageProps { suspended: boolean; hidden: boolean; blockedBy: boolean; accountId?: string; withoutAddCollectionButton?: boolean; } export const EmptyMessage: React.FC = ({ accountId, suspended, hidden, blockedBy, withoutAddCollectionButton, }) => { const me = useCurrentAccountId(); const account = useAccount(accountId); const dispatch = useAppDispatch(); const confirmHideFeaturedTab = useCallback(() => { void dispatch( openModal({ modalType: 'ACCOUNT_HIDE_FEATURED_TAB', modalProps: {}, }), ); }, [dispatch]); if (!accountId) { return null; } let title: React.ReactNode = null; let message: React.ReactNode = null; const hasCollections = areCollectionsEnabled(); if (me === accountId) { if (hasCollections) { // Return only here to insert the "Create a collection" button as the action for the empty state. return ( } message={ } > {!withoutAddCollectionButton && ( )} ); } else { title = ( ); message = ( ); } } else if (suspended) { title = ( ); } else if (hidden) { message = ; } else if (blockedBy) { title = ( ); } else { if (account) { title = ( }} /> ); } else { title = ( ); } } return ; };