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
This commit is contained in:
parent
ae3d0107f8
commit
02780faa6c
4 changed files with 23 additions and 7 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,6 +383,23 @@ exports[`PostHeader should match snapshot when post is same thread, so dont disp
|
|||
/>
|
||||
</View>
|
||||
</View>
|
||||
<FormattedText
|
||||
defaultMessage="Commented on {name}{apostrophe} message: "
|
||||
id="post_body.commentedOn"
|
||||
style={
|
||||
Object {
|
||||
"color": "rgba(61,60,64,0.65)",
|
||||
"lineHeight": 21,
|
||||
"marginBottom": 3,
|
||||
}
|
||||
}
|
||||
values={
|
||||
Object {
|
||||
"apostrophe": "'s",
|
||||
"name": "John Doe",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
`;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue