From 02780faa6c2cbea1b1bc6011c9ed86b692d0eb4a Mon Sep 17 00:00:00 2001 From: CJ <38697367+imisshtml@users.noreply.github.com> Date: Thu, 12 Dec 2019 19:25:00 -0500 Subject: [PATCH] MM-18054 Fix Comment Line showing (#3696) * MM-18054 Fix Comment Line showing Restructured the check for the previous post to make sure comment line does not appear for posts on same thread, but from different users. * MM-18054 Updated after review Updated the logic to be more bulletproof --- app/components/post/index.js | 6 ++++-- app/components/post/post.js | 2 -- .../__snapshots__/post_header.test.js.snap | 17 +++++++++++++++++ app/components/post_header/post_header.js | 5 ++--- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/components/post/index.js b/app/components/post/index.js index ae76dd5b6..ef208d651 100644 --- a/app/components/post/index.js +++ b/app/components/post/index.js @@ -10,6 +10,7 @@ import {isChannelReadOnlyById} from 'mattermost-redux/selectors/entities/channel import {getPost, makeGetCommentCountForPost, makeIsPostCommentMention} from 'mattermost-redux/selectors/entities/posts'; import {getUser, getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; import {getMyPreferences, getTheme} from 'mattermost-redux/selectors/entities/preferences'; +import {isStartOfNewMessages} from 'mattermost-redux/utils/post_list'; import {isPostFlagged, isSystemMessage} from 'mattermost-redux/utils/post_utils'; import {insertToDraft, setPostTooltipVisible} from 'app/actions/views/channel'; @@ -40,7 +41,8 @@ function makeMapStateToProps() { const isPostCommentMention = makeIsPostCommentMention(); return function mapStateToProps(state, ownProps) { const post = ownProps.post || getPost(state, ownProps.postId); - const previousPost = getPost(state, ownProps.previousPostId); + const previousPostId = isStartOfNewMessages(ownProps.previousPostId) ? ownProps.beforePrevPostId : ownProps.previousPostId; + const previousPost = getPost(state, previousPostId); const beforePrevPost = getPost(state, ownProps.beforePrevPostId); const myPreferences = getMyPreferences(state); @@ -52,7 +54,7 @@ function makeMapStateToProps() { let commentedOnPost = null; if (ownProps.renderReplies && post && post.root_id) { - if (ownProps.previousPostId) { + if (previousPostId) { if (previousPost && (previousPost.id === post.root_id || previousPost.root_id === post.root_id)) { // Previous post is root post or previous post is in same thread isFirstReply = false; diff --git a/app/components/post/post.js b/app/components/post/post.js index d008271aa..1afd68ce4 100644 --- a/app/components/post/post.js +++ b/app/components/post/post.js @@ -254,7 +254,6 @@ export default class Post extends PureComponent { isLandscape, previousPostExists, beforePrevPostUserId, - isFirstReply, } = this.props; if (!post) { @@ -306,7 +305,6 @@ export default class Post extends PureComponent { theme={theme} previousPostExists={previousPostExists} beforePrevPostUserId={beforePrevPostUserId} - isFirstReply={isFirstReply} /> ); } diff --git a/app/components/post_header/__snapshots__/post_header.test.js.snap b/app/components/post_header/__snapshots__/post_header.test.js.snap index 1fc62210e..715f2c956 100644 --- a/app/components/post_header/__snapshots__/post_header.test.js.snap +++ b/app/components/post_header/__snapshots__/post_header.test.js.snap @@ -383,6 +383,23 @@ exports[`PostHeader should match snapshot when post is same thread, so dont disp /> + `; diff --git a/app/components/post_header/post_header.js b/app/components/post_header/post_header.js index 7ee9d4708..4dfda604b 100644 --- a/app/components/post_header/post_header.js +++ b/app/components/post_header/post_header.js @@ -46,7 +46,6 @@ export default class PostHeader extends PureComponent { previousPostExists: PropTypes.bool, post: PropTypes.object, beforePrevPostUserId: PropTypes.string, - isFirstReply: PropTypes.bool, isLandscape: PropTypes.bool.isRequired, }; @@ -70,9 +69,9 @@ export default class PostHeader extends PureComponent { previousPostExists, renderReplies, theme, - isFirstReply, } = this.props; - if (!isFirstReply || !renderReplies || !commentedOnDisplayName || (!previousPostExists && post.user_id === beforePrevPostUserId)) { + + if (!renderReplies || !commentedOnDisplayName || (!previousPostExists && post.user_id === beforePrevPostUserId)) { return null; }