import type { ComponentPropsWithoutRef, FC } from 'react'; import { useMemo } from 'react'; import classNames from 'classnames'; import type { LinkProps } from 'react-router-dom'; import { Link } from 'react-router-dom'; import { EmojiHTML } from '@/flavours/glitch/features/emoji/emoji_html'; import type { Account } from '@/flavours/glitch/models/account'; import { isModernEmojiEnabled } from '@/flavours/glitch/utils/environment'; import { Skeleton } from '../skeleton'; interface Props { account?: Account; localDomain?: string; simple?: boolean; noDomain?: boolean; } export const DisplayName: FC> = ({ account, localDomain, simple = false, noDomain = false, className, ...props }) => { const username = useMemo(() => { if (!account || noDomain) { return null; } let acct = account.get('acct'); if (!acct.includes('@') && localDomain) { acct = `${acct}@${localDomain}`; } return `@${acct}`; }, [account, localDomain, noDomain]); if (!account) { if (simple) { return null; } return ( {!noDomain && (   )} ); } const accountName = isModernEmojiEnabled() ? account.get('display_name') : account.get('display_name_html'); if (simple) { return ( ); } return ( {username && (  {username} )} ); }; export const LinkedDisplayName: FC< Props & { asProps?: ComponentPropsWithoutRef<'span'> } & Partial > = ({ account, asProps = {}, className, localDomain, simple, noDomain, ...linkProps }) => { const displayProps = { account, className, localDomain, simple, noDomain, ...asProps, }; if (!account) { return ; } return ( ); };