From d7ee335106b4f3497d78f2e48d356f0ea89fea27 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Fri, 9 Dec 2016 07:53:36 -0500 Subject: Fixed being unable to make the first post in a new channel (#4744) --- webapp/components/post_view/post_view_controller.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'webapp/components') 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: -- cgit v1.2.3-1-g7c22