From 3fbecb2f0db882f4e0acd07a5b51504e0a7860d2 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sat, 8 Jun 2024 21:35:14 +0800 Subject: [PATCH] Fix NameText not showing username when short --- src/components/name-text.jsx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/name-text.jsx b/src/components/name-text.jsx index 48c6a743..97b94e86 100644 --- a/src/components/name-text.jsx +++ b/src/components/name-text.jsx @@ -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 ( - {!showAcct && username && ( + {!showAcct && !hideUsername && ( <> {' '} @{username}