mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-27 01:50:47 +00:00
Copy username and instance easily
This commit is contained in:
parent
0219b7cad7
commit
5e5069f2b7
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user