Automated cherry pick of #3786 (#3800)

* MM-21230 Added check for first post

Added a check to see if there was an original postId to validate the moreMessages check.

* Added comment
This commit is contained in:
Mattermost Build 2020-01-13 16:27:51 +01:00 committed by Amy Blais
parent a058941288
commit e5d1a08767

View file

@ -236,16 +236,35 @@ export default class PostList extends PureComponent {
};
renderItem = ({item, index}) => {
const {
highlightPinnedOrFlagged,
highlightPostId,
isSearchResult,
lastPostIndex,
location,
onHashtagPress,
onPostPress,
postIds,
renderReplies,
shouldRenderReplyButton,
theme,
} = this.props;
if (PostListUtils.isStartOfNewMessages(item)) {
// postIds includes a date item after the new message indicator so 2
// needs to be added to the index for the length check to be correct.
const moreNewMessages = this.props.postIds.length === index + 2;
const moreNewMessages = postIds.length === index + 2;
// The date line and new message line each count for a line. So the
// goal of this is to check for the 3rd previous, which for the start
// of a thread would be null as it doesn't exist.
const checkForPostId = index < postIds.length - 3;
return (
<NewMessagesDivider
index={index}
theme={this.props.theme}
moreMessages={moreNewMessages}
theme={theme}
moreMessages={moreNewMessages && checkForPostId}
/>
);
} else if (PostListUtils.isDateLine(item)) {
@ -259,22 +278,22 @@ 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 previousPostId = index < postIds.length - 1 ? postIds[index + 1] : null;
const beforePrevPostId = index < postIds.length - 2 ? postIds[index + 2] : null;
const nextPostId = index > 0 ? postIds[index - 1] : null;
const postProps = {
previousPostId,
nextPostId,
highlightPinnedOrFlagged: this.props.highlightPinnedOrFlagged,
isSearchResult: this.props.isSearchResult,
location: this.props.location,
highlightPinnedOrFlagged,
isSearchResult,
location,
managedConfig: mattermostManaged.getCachedConfig(),
onHashtagPress: this.props.onHashtagPress,
onHashtagPress,
onPermalinkPress: this.handlePermalinkPress,
onPress: this.props.onPostPress,
renderReplies: this.props.renderReplies,
shouldRenderReplyButton: this.props.shouldRenderReplyButton,
onPress: onPostPress,
renderReplies,
shouldRenderReplyButton,
beforePrevPostId,
};
@ -292,8 +311,8 @@ export default class PostList extends PureComponent {
return (
<Post
postId={postId}
highlight={this.props.highlightPostId === postId}
isLastPost={this.props.lastPostIndex === index}
highlight={highlightPostId === postId}
isLastPost={lastPostIndex === index}
{...postProps}
/>
);