fix(posts): limit display name character count

This commit is contained in:
plebeius.eth
2024-03-06 14:43:59 +01:00
parent 13b7b94a53
commit ff4a97b9b4
2 changed files with 4 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ const PostAuthor = ({
const isAuthorModerator = authorRole === 'moderator';
const moderatorClass = `${isAuthorOwner ? styles.owner : isAuthorAdmin ? styles.admin : isAuthorModerator ? styles.moderator : ''}`;
const authorRoleInitial = (isAuthorOwner && 'O') || (isAuthorAdmin && 'A') || (isAuthorModerator && 'M') || '';
const shortDisplayName = displayName?.length > 20 ? displayName?.slice(0, 20) + '...' : displayName;
return (
<>
@@ -60,7 +61,7 @@ const PostAuthor = ({
) : (
<> </>
)}
{displayName && <span className={`${styles.displayName} ${moderatorClass}`}>{displayName} </span>}
{displayName && <span className={`${styles.displayName} ${moderatorClass}`}>{shortDisplayName} </span>}
<span className={`${styles.authorAddressWrapper} ${moderatorClass}`}>
<span className={styles.authorAddressHidden}>u/{shortAddress || shortAuthorAddress}</span>
<span className={`${styles.authorAddressVisible} ${authorAddressChanged && styles.authorAddressChanged}`}>u/{shortAuthorAddress}</span>

View File

@@ -39,6 +39,7 @@ const ReplyAuthor = ({ address, authorRole, cid, displayName, imageUrl, isAvatar
const isAuthorModerator = authorRole === 'moderator';
const authorRoleInitial = (isAuthorOwner && 'O') || (isAuthorAdmin && 'A') || (isAuthorModerator && 'M') || '';
const moderatorClass = `${isAuthorOwner ? styles.owner : isAuthorAdmin ? styles.admin : isAuthorModerator ? styles.moderator : ''}`;
const shortDisplayName = displayName?.length > 20 ? displayName?.slice(0, 20) + '...' : displayName;
return (
<>
@@ -49,7 +50,7 @@ const ReplyAuthor = ({ address, authorRole, cid, displayName, imageUrl, isAvatar
)}
{displayName && (
<Link to={`/u/${address}/c/${cid}`} className={`${styles.author} ${moderatorClass}`}>
{displayName}{' '}
{shortDisplayName}{' '}
</Link>
)}
<Link to={`/u/${address}/c/${cid}`} className={`${styles.author} ${moderatorClass}`}>