Skip to content

Commit f74a297

Browse files
vladislavkeblyshihor-romaniuk
authored andcommitted
feat: add profile image to comment header
1 parent 9e5c1f1 commit f74a297

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/discussions/post-comments/comments/comment/Comment.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const Comment = ({
4343
const {
4444
id, parentId, childCount, abuseFlagged, endorsed, threadId, endorsedAt, endorsedBy, endorsedByLabel, renderedBody,
4545
voted, following, voteCount, authorLabel, author, createdAt, lastEdit, rawBody, closed, closedBy, closeReason,
46-
editByLabel, closedByLabel,
46+
editByLabel, closedByLabel, users: postUsers,
4747
} = comment;
4848
const intl = useIntl();
4949
const hasChildren = childCount > 0;
@@ -203,6 +203,7 @@ const Comment = ({
203203
closed={closed}
204204
createdAt={createdAt}
205205
lastEdit={lastEdit}
206+
postUsers={postUsers}
206207
/>
207208
{isEditing ? (
208209
<CommentEditor

src/discussions/post-comments/comments/comment/CommentHeader.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const CommentHeader = ({
1515
closed,
1616
createdAt,
1717
lastEdit,
18+
postUsers,
1819
}) => {
1920
const colorClass = AvatarOutlineAndLabelColors[authorLabel];
2021
const hasAnyAlert = useAlertBannerVisible({
@@ -24,6 +25,8 @@ const CommentHeader = ({
2425
closed,
2526
});
2627

28+
const profileImage = postUsers && Object.values(postUsers)[0].profile.image;
29+
2730
return (
2831
<div className={classNames('d-flex flex-row justify-content-between', {
2932
'mt-2': hasAnyAlert,
@@ -33,6 +36,7 @@ const CommentHeader = ({
3336
<Avatar
3437
className={`border-0 ml-0.5 mr-2.5 ${colorClass ? `outline-${colorClass}` : 'outline-anonymous'}`}
3538
alt={author}
39+
src={profileImage?.hasImage ? profileImage?.imageUrlSmall : undefined}
3640
style={{
3741
width: '32px',
3842
height: '32px',
@@ -61,6 +65,7 @@ CommentHeader.propTypes = {
6165
editorUsername: PropTypes.string,
6266
reason: PropTypes.string,
6367
}),
68+
postUsers: PropTypes.shape({}).isRequired,
6469
};
6570

6671
CommentHeader.defaultProps = {

src/discussions/posts/post/PostHeader.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const PostAvatar = React.memo(({
3737
return spacing;
3838
}, [postType]);
3939

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

4242
return (
4343
<div className={avatarSpacing}>

0 commit comments

Comments
 (0)