diff options
author | =Corey Hulen <corey@hulen.com> | 2015-09-14 16:59:24 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-09-14 16:59:24 -0700 |
commit | 3bd350dcaf65a89040f7ea395a19b620819ba03e (patch) | |
tree | 72b49e6fadfc1d513489b8938d5f73620ff2a6d8 /web/react/components/post_list.jsx | |
parent | e06e292be71ca699d90bafbd635118aa47c2d7a5 (diff) | |
parent | bfebb41bc0c0a1c5f481617f912bdf6dd483c341 (diff) | |
download | chat-3bd350dcaf65a89040f7ea395a19b620819ba03e.tar.gz chat-3bd350dcaf65a89040f7ea395a19b620819ba03e.tar.bz2 chat-3bd350dcaf65a89040f7ea395a19b620819ba03e.zip |
Merge branch 'master' into PLT-12-log
Diffstat (limited to 'web/react/components/post_list.jsx')
-rw-r--r-- | web/react/components/post_list.jsx | 12 |
1 files changed, 9 insertions, 3 deletions
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); |