From d7cdcf082fab6c0cb7c2fe4bed821bd1a8000e69 Mon Sep 17 00:00:00 2001
From: Christopher Speller <crspeller@gmail.com>
Date: Mon, 8 Feb 2016 07:26:10 -0500
Subject: Convering client to react-router.

---
 web/react/components/post_focus_view.jsx | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

(limited to 'web/react/components/post_focus_view.jsx')

diff --git a/web/react/components/post_focus_view.jsx b/web/react/components/post_focus_view.jsx
index 44a0bae09..fd654f502 100644
--- a/web/react/components/post_focus_view.jsx
+++ b/web/react/components/post_focus_view.jsx
@@ -5,7 +5,8 @@ import PostsView from './posts_view.jsx';
 
 import PostStore from '../stores/post_store.jsx';
 import ChannelStore from '../stores/channel_store.jsx';
-import * as EventHelpers from '../dispatcher/event_helpers.jsx';
+import UserStore from '../stores/user_store.jsx';
+import * as GlobalActions from '../action_creators/global_actions.jsx';
 
 import {FormattedMessage} from 'mm-intl';
 
@@ -15,6 +16,7 @@ export default class PostFocusView extends React.Component {
 
         this.onChannelChange = this.onChannelChange.bind(this);
         this.onPostsChange = this.onPostsChange.bind(this);
+        this.onUserChange = this.onUserChange.bind(this);
         this.handlePostsViewScroll = this.handlePostsViewScroll.bind(this);
         this.loadMorePostsTop = this.loadMorePostsTop.bind(this);
         this.loadMorePostsBottom = this.loadMorePostsBottom.bind(this);
@@ -26,18 +28,21 @@ export default class PostFocusView extends React.Component {
             scrollPostId: focusedPostId,
             postList: PostStore.getVisiblePosts(focusedPostId),
             atTop: PostStore.getVisibilityAtTop(focusedPostId),
-            atBottom: PostStore.getVisibilityAtBottom(focusedPostId)
+            atBottom: PostStore.getVisibilityAtBottom(focusedPostId),
+            currentUser: UserStore.getCurrentUser()
         };
     }
 
     componentDidMount() {
         ChannelStore.addChangeListener(this.onChannelChange);
         PostStore.addChangeListener(this.onPostsChange);
+        UserStore.addChangeListener(this.onUserChange);
     }
 
     componentWillUnmount() {
         ChannelStore.removeChangeListener(this.onChannelChange);
         PostStore.removeChangeListener(this.onPostsChange);
+        UserStore.removeChangeListener(this.onUserChange);
     }
 
     onChannelChange() {
@@ -46,6 +51,10 @@ export default class PostFocusView extends React.Component {
         });
     }
 
+    onUserChange() {
+        this.setState({currentUser: UserStore.getCurrentUser()});
+    }
+
     onPostsChange() {
         const focusedPostId = PostStore.getFocusedPostId();
         if (focusedPostId == null) {
@@ -65,11 +74,11 @@ export default class PostFocusView extends React.Component {
     }
 
     loadMorePostsTop() {
-        EventHelpers.emitLoadMorePostsFocusedTopEvent();
+        GlobalActions.emitLoadMorePostsFocusedTopEvent();
     }
 
     loadMorePostsBottom() {
-        EventHelpers.emitLoadMorePostsFocusedBottomEvent();
+        GlobalActions.emitLoadMorePostsFocusedBottomEvent();
     }
 
     getIntroMessage() {
@@ -89,6 +98,10 @@ export default class PostFocusView extends React.Component {
         const postsToHighlight = {};
         postsToHighlight[this.state.scrollPostId] = true;
 
+        if (!this.state.currentUser || !this.state.postList) {
+            return null;
+        }
+
         return (
             <div id='post-list'>
                 <PostsView
@@ -106,6 +119,7 @@ export default class PostFocusView extends React.Component {
                     messageSeparatorTime={0}
                     postsToHighlight={postsToHighlight}
                     profiles={this.props.profiles}
+                    currentUser={this.state.currentUser}
                 />
             </div>
         );
-- 
cgit v1.2.3-1-g7c22

