From 3ace4fd92fdd6ba6e964c48b1dcbe081625232ee Mon Sep 17 00:00:00 2001 From: vladislavkeblysh Date: Wed, 11 Oct 2023 20:02:21 +0300 Subject: [PATCH] feat: add profile image to avatar --- src/discussions/posts/post/Post.jsx | 3 ++- src/discussions/posts/post/PostHeader.jsx | 10 ++++++++-- src/discussions/posts/post/PostLink.jsx | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/discussions/posts/post/Post.jsx b/src/discussions/posts/post/Post.jsx index 423ffe13d..935372672 100644 --- a/src/discussions/posts/post/Post.jsx +++ b/src/discussions/posts/post/Post.jsx @@ -32,7 +32,7 @@ const Post = ({ handleAddResponseButton }) => { const { topicId, abuseFlagged, closed, pinned, voted, hasEndorsed, following, closedBy, voteCount, groupId, groupName, closeReason, authorLabel, type: postType, author, title, createdAt, renderedBody, lastEdit, editByLabel, - closedByLabel, + closedByLabel, users: postUsers, } = useSelector(selectThread(postId)); const intl = useIntl(); const location = useLocation(); @@ -182,6 +182,7 @@ const Post = ({ handleAddResponseButton }) => { lastEdit={lastEdit} postType={postType} title={title} + postUsers={postUsers} />
diff --git a/src/discussions/posts/post/PostHeader.jsx b/src/discussions/posts/post/PostHeader.jsx index eeb38878d..33b6ec144 100644 --- a/src/discussions/posts/post/PostHeader.jsx +++ b/src/discussions/posts/post/PostHeader.jsx @@ -13,7 +13,7 @@ import { useAlertBannerVisible } from '../../data/hooks'; import messages from './messages'; export const PostAvatar = React.memo(({ - author, postType, authorLabel, fromPostLink, read, + author, postType, authorLabel, fromPostLink, read, postUsers, }) => { const outlineColor = AvatarOutlineAndLabelColors[authorLabel]; @@ -37,6 +37,8 @@ export const PostAvatar = React.memo(({ return spacing; }, [postType]); + const profileImage = Object.values(postUsers)[0].profile.image; + return (
{postType === ThreadType.QUESTION && ( @@ -59,6 +61,7 @@ export const PostAvatar = React.memo(({ height: avatarSize, width: avatarSize, }} + src={profileImage?.hasImage ? profileImage?.imageUrlSmall : undefined} alt={author} />
@@ -71,6 +74,7 @@ PostAvatar.propTypes = { authorLabel: PropTypes.string, fromPostLink: PropTypes.bool, read: PropTypes.bool, + postUsers: PropTypes.shape({}).isRequired, }; PostAvatar.defaultProps = { @@ -90,6 +94,7 @@ const PostHeader = ({ title, postType, preview, + postUsers, }) => { const intl = useIntl(); const showAnsweredBadge = preview && hasEndorsed && postType === ThreadType.QUESTION; @@ -101,7 +106,7 @@ const PostHeader = ({ return (
- +
@@ -151,6 +156,7 @@ PostHeader.propTypes = { reason: PropTypes.string, }), closed: PropTypes.bool, + postUsers: PropTypes.shape({}).isRequired, }; PostHeader.defaultProps = { diff --git a/src/discussions/posts/post/PostLink.jsx b/src/discussions/posts/post/PostLink.jsx index 63f7659d6..5501fba1c 100644 --- a/src/discussions/posts/post/PostLink.jsx +++ b/src/discussions/posts/post/PostLink.jsx @@ -36,6 +36,7 @@ const PostLink = ({ const { topicId, hasEndorsed, type, author, authorLabel, abuseFlagged, abuseFlaggedCount, read, commentCount, unreadCommentCount, id, pinned, previewBody, title, voted, voteCount, following, groupId, groupName, createdAt, + users: postUsers, } = useSelector(selectThread(postId)); const { pathname } = discussionsPath(Routes.COMMENTS.PAGES[page], { 0: enableInContextSidebar ? 'in-context' : undefined, @@ -83,6 +84,7 @@ const PostLink = ({ authorLabel={authorLabel} fromPostLink read={isPostRead} + postUsers={postUsers} />