import { useCallback, useId, useRef, useState } from 'react'; import type { FC } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import classNames from 'classnames'; import Overlay from 'react-overlays/esm/Overlay'; import { DisplayName } from '@/mastodon/components/display_name'; import { Icon } from '@/mastodon/components/icon'; import { useAccount } from '@/mastodon/hooks/useAccount'; import { useAppSelector } from '@/mastodon/store'; import AtIcon from '@/material-icons/400-24px/alternate_email.svg?react'; import HelpIcon from '@/material-icons/400-24px/help.svg?react'; import DomainIcon from '@/material-icons/400-24px/language.svg?react'; import classes from './redesign.module.scss'; const messages = defineMessages({ lockedInfo: { id: 'account.locked_info', defaultMessage: 'This account privacy status is set to locked. The owner manually reviews who can follow them.', }, nameInfo: { id: 'account.name_info', defaultMessage: 'What does this mean?', }, }); export const AccountName: FC<{ accountId: string }> = ({ accountId }) => { const account = useAccount(accountId); const me = useAppSelector((state) => state.meta.get('me') as string); const localDomain = useAppSelector( (state) => state.meta.get('domain') as string, ); if (!account) { return null; } const [username = '', domain = localDomain] = account.acct.split('@'); return (

@{username}@{domain}

); }; const AccountNameHelp: FC<{ username: string; domain: string; isSelf: boolean; }> = ({ username, domain, isSelf }) => { const accessibilityId = useId(); const intl = useIntl(); const [open, setOpen] = useState(false); const triggerRef = useRef(null); const handleClick = useCallback(() => { setOpen((prev) => !prev); }, []); return ( <> {({ props }) => (
  1. {isSelf ? ( {username} }} tagName='p' /> ) : ( {username} }} tagName='p' /> )}
  2. {isSelf ? ( {domain} }} tagName='p' /> ) : ( {domain} }} tagName='p' /> )}
)}
); };