MM-18054: Removed Commented On from new messages in thread with same poster (#3351)

* MM-18054:

Added a check for previousPost to use in validating new messages in thread to check if we should display Commented On message.

* MM-18054 Updated

Updated the check for Commented line to validate the previous thread was one that the post user commente on.

* MM-18054 Fixed Eslint Issues

Fixed Eslint Issues

* MM-18054 Fixed Eslint Issues

Missed a space...

* MM-18054 Cleanup

Cleaned up some code from suggestions
This commit is contained in:
CJ 2019-10-12 01:31:55 -04:00 committed by GitHub
parent ff3ba8ea01
commit 0d7d1b7542
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 2 deletions

View file

@ -41,6 +41,7 @@ function makeMapStateToProps() {
return function mapStateToProps(state, ownProps) {
const post = ownProps.post || getPost(state, ownProps.postId);
const previousPost = getPost(state, ownProps.previousPostId);
const beforePrevPost = getPost(state, ownProps.beforePrevPostId);
const myPreferences = getMyPreferences(state);
const currentUserId = getCurrentUserId(state);
@ -84,6 +85,8 @@ function makeMapStateToProps() {
isFlagged: isPostFlagged(post.id, myPreferences),
isCommentMention,
isLandscape: isLandscape(state),
previousPostExists: Boolean(previousPost),
beforePrevPostUserId: (beforePrevPost ? beforePrevPost.user_id : null),
};
};
}

View file

@ -68,6 +68,8 @@ export default class Post extends PureComponent {
location: PropTypes.string,
isBot: PropTypes.bool,
isLandscape: PropTypes.bool.isRequired,
previousPostExists: PropTypes.bool,
beforePrevPostUserId: PropTypes.string,
};
static defaultProps = {
@ -250,6 +252,8 @@ export default class Post extends PureComponent {
skipPinnedHeader,
location,
isLandscape,
previousPostExists,
beforePrevPostUserId,
} = this.props;
if (!post) {
@ -299,6 +303,8 @@ export default class Post extends PureComponent {
onUsernamePress={onUsernamePress}
renderReplies={renderReplies}
theme={theme}
previousPostExists={previousPostExists}
beforePrevPostUserId={beforePrevPostUserId}
/>
);
}

View file

@ -43,6 +43,9 @@ export default class PostHeader extends PureComponent {
isGuest: PropTypes.bool,
userTimezone: PropTypes.string,
enableTimezone: PropTypes.bool,
previousPostExists: PropTypes.bool,
post: PropTypes.object,
beforePrevPostUserId: PropTypes.string,
};
static defaultProps = {
@ -58,11 +61,18 @@ export default class PostHeader extends PureComponent {
};
renderCommentedOnMessage = () => {
if (!this.props.renderReplies || !this.props.commentedOnDisplayName) {
const {
beforePrevPostUserId,
commentedOnDisplayName,
post,
previousPostExists,
renderReplies,
theme,
} = this.props;
if (!renderReplies || !commentedOnDisplayName || (!previousPostExists && post.user_id === beforePrevPostUserId)) {
return null;
}
const {commentedOnDisplayName, theme} = this.props;
const style = getStyleSheet(theme);
const displayName = commentedOnDisplayName;

View file

@ -260,6 +260,7 @@ export default class PostList extends PureComponent {
// Remember that the list is rendered with item 0 at the bottom so the "previous" post
// comes after this one in the list
const previousPostId = index < this.props.postIds.length - 1 ? this.props.postIds[index + 1] : null;
const beforePrevPostId = index < this.props.postIds.length - 2 ? this.props.postIds[index + 2] : null;
const nextPostId = index > 0 ? this.props.postIds[index - 1] : null;
const postProps = {
@ -274,6 +275,7 @@ export default class PostList extends PureComponent {
onPress: this.props.onPostPress,
renderReplies: this.props.renderReplies,
shouldRenderReplyButton: this.props.shouldRenderReplyButton,
beforePrevPostId,
};
if (PostListUtils.isCombinedUserActivityPost(item)) {