From 431d89f5f6a333bad7811ba8c3aae5736d0b32db Mon Sep 17 00:00:00 2001
From: Saturnino Abril <saturnino.abril@gmail.com>
Date: Mon, 8 May 2017 21:54:42 +0900
Subject: fix JS error when deleting RHS root (#6344)

---
 webapp/components/rhs_thread.jsx | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

(limited to 'webapp/components/rhs_thread.jsx')

diff --git a/webapp/components/rhs_thread.jsx b/webapp/components/rhs_thread.jsx
index da958d9d5..174799878 100644
--- a/webapp/components/rhs_thread.jsx
+++ b/webapp/components/rhs_thread.jsx
@@ -321,18 +321,16 @@ export default class RhsThread extends React.Component {
     }
 
     render() {
-        const postsArray = this.state.postsArray;
-        const selected = this.state.selected;
-        const profiles = this.state.profiles || {};
-        const rootPostDay = Utils.getDateForUnixTicks(selected.create_at);
-        let previousPostDay = rootPostDay;
-
-        if (postsArray == null || selected == null) {
+        if (this.state.postsArray == null || this.state.selected == null) {
             return (
                 <div/>
             );
         }
 
+        const postsArray = this.state.postsArray;
+        const selected = this.state.selected;
+        const profiles = this.state.profiles || {};
+
         let profile;
         if (UserStore.getCurrentId() === selected.user_id) {
             profile = this.props.currentUser;
@@ -350,6 +348,9 @@ export default class RhsThread extends React.Component {
             rootStatus = this.state.statuses[selected.user_id] || 'offline';
         }
 
+        const rootPostDay = Utils.getDateForUnixTicks(selected.create_at);
+        let previousPostDay = rootPostDay;
+
         const commentsLists = [];
         for (let i = 0; i < postsArray.length; i++) {
             const comPost = postsArray[i];
-- 
cgit v1.2.3-1-g7c22

