Copy username and instance easily

This commit is contained in:
Dominik Braun 2025-10-13 00:23:56 +02:00
parent 0219b7cad7
commit 5e5069f2b7

View File

@ -371,6 +371,19 @@ export const AccountHeader: React.FC<{
});
}, [account]);
const handleCopyUsername = useCallback(() => {
if (!account) {
return;
}
const isLocal = !account.acct.includes('@');
const username = account.acct.split('@')[0];
const domain = isLocal ? localDomain : account.acct.split('@')[1];
const fullHandle = `@${username}@${domain}`;
void navigator.clipboard.writeText(fullHandle);
}, [account]);
const suspended = account?.suspended;
const isRemote = account?.acct !== account?.username;
const remoteDomain = isRemote ? account?.acct.split('@')[1] : null;
@ -822,7 +835,11 @@ export const AccountHeader: React.FC<{
<h1>
<DisplayName account={account} variant='simple' />
<small>
<span>
<span
onClick={handleCopyUsername}
style={{ cursor: 'pointer' }}
title={`Click to copy @${username}@${domain}`}
>
@{username}
<span className='invisible'>@{domain}</span>
</span>