Fix NameText not showing username when short
This commit is contained in:
parent
ef1abbc25c
commit
3fbecb2f0d
|
@ -20,9 +20,17 @@ function NameText({
|
||||||
external,
|
external,
|
||||||
onClick,
|
onClick,
|
||||||
}) {
|
}) {
|
||||||
const { acct, avatar, avatarStatic, id, url, displayName, emojis, bot } =
|
const {
|
||||||
account;
|
acct,
|
||||||
let { username } = account;
|
avatar,
|
||||||
|
avatarStatic,
|
||||||
|
id,
|
||||||
|
url,
|
||||||
|
displayName,
|
||||||
|
emojis,
|
||||||
|
bot,
|
||||||
|
username,
|
||||||
|
} = account;
|
||||||
const [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
|
const [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
|
||||||
|
|
||||||
const trimmedUsername = username.toLowerCase().trim();
|
const trimmedUsername = username.toLowerCase().trim();
|
||||||
|
@ -35,16 +43,13 @@ function NameText({
|
||||||
'',
|
'',
|
||||||
); // Remove non-alphanumeric characters
|
); // Remove non-alphanumeric characters
|
||||||
|
|
||||||
if (
|
const hideUsername =
|
||||||
(!short &&
|
(!short &&
|
||||||
(trimmedUsername === trimmedDisplayName ||
|
(trimmedUsername === trimmedDisplayName ||
|
||||||
trimmedUsername === shortenedDisplayName ||
|
trimmedUsername === shortenedDisplayName ||
|
||||||
trimmedUsername === shortenedAlphaNumericDisplayName ||
|
trimmedUsername === shortenedAlphaNumericDisplayName ||
|
||||||
nameCollator.compare(trimmedUsername, shortenedDisplayName) === 0)) ||
|
nameCollator.compare(trimmedUsername, shortenedDisplayName) === 0)) ||
|
||||||
shortenedAlphaNumericDisplayName === acct.toLowerCase()
|
shortenedAlphaNumericDisplayName === acct.toLowerCase();
|
||||||
) {
|
|
||||||
username = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
|
@ -83,7 +88,7 @@ function NameText({
|
||||||
<b>
|
<b>
|
||||||
<EmojiText text={displayName} emojis={emojis} />
|
<EmojiText text={displayName} emojis={emojis} />
|
||||||
</b>
|
</b>
|
||||||
{!showAcct && username && (
|
{!showAcct && !hideUsername && (
|
||||||
<>
|
<>
|
||||||
{' '}
|
{' '}
|
||||||
<i>@{username}</i>
|
<i>@{username}</i>
|
||||||
|
|
Loading…
Reference in a new issue