Skip to content

Commit

Permalink
feat: add profile image to comment header
Browse files Browse the repository at this point in the history
  • Loading branch information
vladislavkeblysh committed Nov 25, 2023
1 parent bc83a12 commit 9367409
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/discussions/post-comments/comments/comment/Comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Comment = ({
const {
id, parentId, childCount, abuseFlagged, endorsed, threadId, endorsedAt, endorsedBy, endorsedByLabel, renderedBody,
voted, following, voteCount, authorLabel, author, createdAt, lastEdit, rawBody, closed, closedBy, closeReason,
editByLabel, closedByLabel,
editByLabel, closedByLabel, users: postUsers,
} = comment;
const intl = useIntl();
const hasChildren = childCount > 0;
Expand Down Expand Up @@ -203,6 +203,7 @@ const Comment = ({
closed={closed}
createdAt={createdAt}
lastEdit={lastEdit}
postUsers={postUsers}
/>
{isEditing ? (
<CommentEditor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const CommentHeader = ({
closed,
createdAt,
lastEdit,
postUsers,
}) => {
const colorClass = AvatarOutlineAndLabelColors[authorLabel];
const hasAnyAlert = useAlertBannerVisible({
Expand All @@ -25,6 +26,8 @@ const CommentHeader = ({
closed,
});

const profileImage = postUsers && Object.values(postUsers)[0].profile.image;

return (
<div className={classNames('d-flex flex-row justify-content-between', {
'mt-2': hasAnyAlert,
Expand All @@ -34,6 +37,7 @@ const CommentHeader = ({
<Avatar
className={`border-0 ml-0.5 mr-2.5 ${colorClass ? `outline-${colorClass}` : 'outline-anonymous'}`}
alt={author}
src={profileImage?.hasImage ? profileImage?.imageUrlSmall : undefined}
style={{
width: '32px',
height: '32px',
Expand Down Expand Up @@ -62,6 +66,7 @@ CommentHeader.propTypes = {
editorUsername: PropTypes.string,
reason: PropTypes.string,
}),
postUsers: PropTypes.shape({}).isRequired,
};

CommentHeader.defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/discussions/posts/post/PostHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const PostAvatar = React.memo(({
return spacing;
}, [postType]);

const profileImage = Object.values(postUsers)[0].profile.image;
const profileImage = postUsers && Object.values(postUsers)[0].profile.image;

return (
<div className={avatarSpacing}>
Expand Down

0 comments on commit 9367409

Please sign in to comment.