diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-12-09 07:53:36 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-12-09 07:53:36 -0500 |
commit | d7ee335106b4f3497d78f2e48d356f0ea89fea27 (patch) | |
tree | aeb4bd7d039361aafbc3197d8f3f6b662819ea59 /webapp | |
parent | 5341e82ad74dfe40e8e18fb3f11401e9de417701 (diff) | |
download | chat-d7ee335106b4f3497d78f2e48d356f0ea89fea27.tar.gz chat-d7ee335106b4f3497d78f2e48d356f0ea89fea27.tar.bz2 chat-d7ee335106b4f3497d78f2e48d356f0ea89fea27.zip |
Fixed being unable to make the first post in a new channel (#4744)
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/components/post_view/post_view_controller.jsx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/webapp/components/post_view/post_view_controller.jsx b/webapp/components/post_view/post_view_controller.jsx index e053db118..a18a73b86 100644 --- a/webapp/components/post_view/post_view_controller.jsx +++ b/webapp/components/post_view/post_view_controller.jsx @@ -191,8 +191,19 @@ export default class PostViewController extends React.Component { onPostsViewJumpRequest(type, postId) { switch (type) { case Constants.PostsViewJumpTypes.BOTTOM: { + let lastViewedBottom; const lastPost = PostStore.getLatestPost(this.state.channel.id); - this.setState({scrollType: ScrollTypes.BOTTOM, lastViewedBottom: lastPost.create_at || new Date().getTime()}); + + if (lastPost && lastPost.create_at) { + lastViewedBottom = lastPost.create_at; + } else { + lastViewedBottom = new Date().getTime(); + } + + this.setState({ + scrollType: ScrollTypes.BOTTOM, + lastViewedBottom + }); break; } case Constants.PostsViewJumpTypes.POST: |