diff --git a/app/components/post/index.js b/app/components/post/index.js index 342fff76a..ae76dd5b6 100644 --- a/app/components/post/index.js +++ b/app/components/post/index.js @@ -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), }; }; } diff --git a/app/components/post/post.js b/app/components/post/post.js index a1a555fb5..1afd68ce4 100644 --- a/app/components/post/post.js +++ b/app/components/post/post.js @@ -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} /> ); } diff --git a/app/components/post_header/post_header.js b/app/components/post_header/post_header.js index fdfa461de..db9b20cdb 100644 --- a/app/components/post_header/post_header.js +++ b/app/components/post_header/post_header.js @@ -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; diff --git a/app/components/post_list/post_list.js b/app/components/post_list/post_list.js index 2ec97afee..87f228c82 100644 --- a/app/components/post_list/post_list.js +++ b/app/components/post_list/post_list.js @@ -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)) {