Fix NameText not showing username when short

This commit is contained in:
Lim Chee Aun 2024-06-08 21:35:14 +08:00
parent ef1abbc25c
commit 3fbecb2f0d

View file

@ -20,9 +20,17 @@ function NameText({
external,
onClick,
}) {
const { acct, avatar, avatarStatic, id, url, displayName, emojis, bot } =
account;
let { username } = account;
const {
acct,
avatar,
avatarStatic,
id,
url,
displayName,
emojis,
bot,
username,
} = account;
const [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
const trimmedUsername = username.toLowerCase().trim();
@ -35,16 +43,13 @@ function NameText({
'',
); // Remove non-alphanumeric characters
if (
const hideUsername =
(!short &&
(trimmedUsername === trimmedDisplayName ||
trimmedUsername === shortenedDisplayName ||
trimmedUsername === shortenedAlphaNumericDisplayName ||
nameCollator.compare(trimmedUsername, shortenedDisplayName) === 0)) ||
shortenedAlphaNumericDisplayName === acct.toLowerCase()
) {
username = null;
}
shortenedAlphaNumericDisplayName === acct.toLowerCase();
return (
<a
@ -83,7 +88,7 @@ function NameText({
<b>
<EmojiText text={displayName} emojis={emojis} />
</b>
{!showAcct && username && (
{!showAcct && !hideUsername && (
<>
{' '}
<i>@{username}</i>