diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2015-09-11 11:47:45 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2015-09-11 11:47:45 -0400 |
commit | d88b745eec8019efdaa1a237393bd945957a3990 (patch) | |
tree | 371db66699cd41eb82dbbbb67bbd084b13a7c4df /web | |
parent | 2709b5f84753913d89682142acb53c74c50c7d77 (diff) | |
parent | 83931da9f2b3eb5e8dc835313992c7ba2ea65f4a (diff) | |
download | chat-d88b745eec8019efdaa1a237393bd945957a3990.tar.gz chat-d88b745eec8019efdaa1a237393bd945957a3990.tar.bz2 chat-d88b745eec8019efdaa1a237393bd945957a3990.zip |
Merge pull request #651 from mattermost/plt-207
PLT-207 Fix load more posts bug.
Diffstat (limited to 'web')
-rw-r--r-- | web/react/components/post.jsx | 2 | ||||
-rw-r--r-- | web/react/components/post_list.jsx | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/web/react/components/post.jsx b/web/react/components/post.jsx index 37de4ecc0..d3c6befd0 100644 --- a/web/react/components/post.jsx +++ b/web/react/components/post.jsx @@ -152,7 +152,7 @@ export default class Post extends React.Component { return ( <div> <div - id={post.id} + id={'post_' + post.id} className={'post ' + sameUserClass + ' ' + rootUser + ' ' + postType + ' ' + currentUserCss} > {profilePic} diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx index 9d95887d9..e6aa3f8df 100644 --- a/web/react/components/post_list.jsx +++ b/web/react/components/post_list.jsx @@ -189,9 +189,15 @@ export default class PostList extends React.Component { this.scrollToBottom(true); // the user clicked 'load more messages' - } else if (this.gotMorePosts) { - var lastPost = oldPosts[oldOrder[prevState.numToDisplay]]; - $('#' + lastPost.id)[0].scrollIntoView(); + } else if (this.gotMorePosts && oldOrder.length > 0) { + let index; + if (prevState.numToDisplay >= oldOrder.length) { + index = oldOrder.length - 1; + } else { + index = prevState.numToDisplay; + } + const lastPost = oldPosts[oldOrder[index]]; + $('#post_' + lastPost.id)[0].scrollIntoView(); this.gotMorePosts = false; } else { this.scrollTo(this.prevScrollTop); |