From 7c9d0c313f8ba935cfd5c33137c6cbdd1c1e6604 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Mon, 16 Jan 2017 16:51:46 -0500 Subject: PLT-5173 fixing javascript error when creating DM on Android (#5077) --- webapp/components/post_view/post_view_controller.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webapp/components/post_view/post_view_controller.jsx b/webapp/components/post_view/post_view_controller.jsx index a18a73b86..a18d0ac38 100644 --- a/webapp/components/post_view/post_view_controller.jsx +++ b/webapp/components/post_view/post_view_controller.jsx @@ -229,8 +229,16 @@ export default class PostViewController extends React.Component { onPostListScroll(atBottom) { if (atBottom) { + 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}); } else { this.setState({scrollType: ScrollTypes.FREE}); } -- cgit v1.2.3-1-g7c22