Add basic UI support for invalid handles in Web UI (#40045)

This commit is contained in:
Claire authored and GitHub committed 2026-08-06 14:24:28 +00:00
1 parent d303a23f7f
commit e21dc88ce9
11 files changed
+163 -50

No files matched your search

@@ -1,26 +1,42 @@
import { useMemo } from 'react';
import type { ComponentPropsWithoutRef, FC } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { Skeleton } from '../skeleton';
import type { DisplayNameProps } from './index';
import { DisplayNameWithoutDomain } from './no-domain';
const messages = defineMessages({
invalidHandle: {
id: 'account.hame.invalid_handle',
defaultMessage: 'Handle unavailable',
},
});
export function useAccountHandle(
account: DisplayNameProps['account'],
localDomain: DisplayNameProps['localDomain'],
) {
const intl = useIntl();
return useMemo(() => {
if (!account) {
return null;
}
if (account.invalid_handle)
return intl.formatMessage(messages.invalidHandle);
let acct = account.acct;
if (!acct.includes('@') && localDomain) {
acct = `${acct}@${localDomain}`;
}
return `@${acct}`;
}, [account, localDomain]);
}, [account, localDomain, intl]);
}
export const DisplayNameDefault: FC<