From b3a71d8c9464205d8e31abd399c85cfdf1292a7e Mon Sep 17 00:00:00 2001 From: James Morris Date: Fri, 5 Aug 2022 09:59:05 +0100 Subject: [PATCH] Fixed the avatar icon to only show if there is no image but no name - This changes the behaviour of the Avatar component to show the icon properly - This removes a parameter from the Avatar component refs https://github.com/TryGhost/Team/issues/1746 --- apps/comments-ui/src/components/Avatar.js | 18 ++++++++---------- apps/comments-ui/src/components/Form.js | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/comments-ui/src/components/Avatar.js b/apps/comments-ui/src/components/Avatar.js index 256cd6a095..a9800ad246 100644 --- a/apps/comments-ui/src/components/Avatar.js +++ b/apps/comments-ui/src/components/Avatar.js @@ -5,6 +5,7 @@ import {ReactComponent as AvatarIcon} from '../images/icons/avatar.svg'; const Avatar = (props) => { const {member} = useContext(AppContext); + const memberName = member?.name ?? props.comment?.member?.name; const getHashOfString = (str) => { let hash = 0; @@ -68,9 +69,13 @@ const Avatar = (props) => { let avatarEl = ( <> -
-

{ commentGetInitials() }

-
+ {memberName ? + (
+

{ commentGetInitials() }

+
) : + (
+ +
)} {commentMember && Avatar} ); @@ -82,13 +87,6 @@ const Avatar = (props) => { ); - // When an avatar has no name - } else if (props.isAnonymous) { - avatarEl = ( -
- -
- ); } return ( diff --git a/apps/comments-ui/src/components/Form.js b/apps/comments-ui/src/components/Form.js index 90bca096fd..c4fdc2a2eb 100644 --- a/apps/comments-ui/src/components/Form.js +++ b/apps/comments-ui/src/components/Form.js @@ -397,7 +397,7 @@ const Form = (props) => {
- +