diff --git a/webapp/channels/src/components/post_view/commented_on/__snapshots__/commented_on.test.tsx.snap b/webapp/channels/src/components/post_view/commented_on/__snapshots__/commented_on.test.tsx.snap
index 844456614d..4aafd43180 100644
--- a/webapp/channels/src/components/post_view/commented_on/__snapshots__/commented_on.test.tsx.snap
+++ b/webapp/channels/src/components/post_view/commented_on/__snapshots__/commented_on.test.tsx.snap
@@ -14,14 +14,9 @@ exports[`components/post_view/CommentedOn should match snapshot 1`] = `
"name":
-
,
@@ -52,14 +47,9 @@ exports[`components/post_view/CommentedOn should match snapshot 2`] = `
"name":
-
,
@@ -90,14 +80,9 @@ exports[`components/post_view/CommentedOn should match snapshot 3`] = `
"name":
-
,
@@ -130,14 +115,9 @@ exports[`components/post_view/CommentedOn should match snapshots for post with p
"name":
-
,
@@ -168,14 +148,9 @@ exports[`components/post_view/CommentedOn should match snapshots for post with p
"name":
-
,
@@ -206,14 +181,9 @@ exports[`components/post_view/CommentedOn should match snapshots for post with p
"name":
-
,
@@ -244,14 +214,9 @@ exports[`components/post_view/CommentedOn should match snapshots for post with p
"name":
-
,
diff --git a/webapp/channels/src/components/post_view/commented_on/commented_on.tsx b/webapp/channels/src/components/post_view/commented_on/commented_on.tsx
index f2ff974461..4627b4c945 100644
--- a/webapp/channels/src/components/post_view/commented_on/commented_on.tsx
+++ b/webapp/channels/src/components/post_view/commented_on/commented_on.tsx
@@ -1,29 +1,27 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import React, {PureComponent} from 'react';
+import React, {memo} from 'react';
import {FormattedMessage} from 'react-intl';
import {UserProfile as UserProfileType} from '@mattermost/types/users';
-
import {Post} from '@mattermost/types/posts';
import * as Utils from 'utils/utils';
import {stripMarkdown} from 'utils/markdown';
import CommentedOnFilesMessage from 'components/post_view/commented_on_files_message';
-import UserProfile from '../../user_profile/user_profile';
+import UserProfile from 'components/user_profile';
type Props = {
enablePostUsernameOverride?: boolean;
parentPostUser?: UserProfileType;
onCommentClick?: React.EventHandler;
post: Post;
-}
+};
-export default class CommentedOn extends PureComponent {
- makeCommentedOnMessage = () => {
- const {post} = this.props;
+function CommentedOn({post, parentPostUser, onCommentClick}: Props) {
+ const makeCommentedOnMessage = () => {
let message: React.ReactNode = '';
if (post.message) {
message = Utils.replaceHtmlEntities(post.message);
@@ -31,7 +29,7 @@ export default class CommentedOn extends PureComponent {
message = (
);
- } else if (post.props && post.props.attachments && post.props.attachments.length > 0) {
+ } else if (post.props?.attachments?.length > 0) {
const attachment = post.props.attachments[0];
const webhookMessage = attachment.pretext || attachment.title || attachment.text || attachment.fallback || '';
message = Utils.replaceHtmlEntities(webhookMessage);
@@ -40,42 +38,40 @@ export default class CommentedOn extends PureComponent {
return message;
};
- render() {
- const message = this.makeCommentedOnMessage();
- const parentPostUser = this.props.parentPostUser;
- const parentPostUserId = (parentPostUser && parentPostUser.id) || '';
+ const message = makeCommentedOnMessage();
+ const parentPostUserId = parentPostUser?.id || '';
- const parentUserProfile = (
-
- );
+ const parentUserProfile = (
+
+ );
- return (
-
- );
- }
+ return (
+
+ );
}
+
+export default memo(CommentedOn);