From 9b30fad8ad4d9d83fd119ed9e4bfb591ebca46e2 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Wed, 17 Feb 2016 14:23:09 -0500
Subject: Refactor user store listener out of channel header

---
 web/react/components/center_panel.jsx | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

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

diff --git a/web/react/components/center_panel.jsx b/web/react/components/center_panel.jsx
index 6cb749075..97c615768 100644
--- a/web/react/components/center_panel.jsx
+++ b/web/react/components/center_panel.jsx
@@ -27,20 +27,24 @@ export default class CenterPanel extends React.Component {
 
         this.onPreferenceChange = this.onPreferenceChange.bind(this);
         this.onChannelChange = this.onChannelChange.bind(this);
+        this.onUserChange = this.onUserChange.bind(this);
 
         const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999);
         this.state = {
             showTutorialScreens: tutorialStep === TutorialSteps.INTRO_SCREENS,
-            showPostFocus: ChannelStore.getPostMode() === ChannelStore.POST_MODE_FOCUS
+            showPostFocus: ChannelStore.getPostMode() === ChannelStore.POST_MODE_FOCUS,
+            user: UserStore.getCurrentUser()
         };
     }
     componentDidMount() {
         PreferenceStore.addChangeListener(this.onPreferenceChange);
         ChannelStore.addChangeListener(this.onChannelChange);
+        UserStore.addChangeListener(this.onUserChange);
     }
     componentWillUnmount() {
         PreferenceStore.removeChangeListener(this.onPreferenceChange);
         ChannelStore.removeChangeListener(this.onChannelChange);
+        UserStore.removeChangeListener(this.onUserChange);
     }
     onPreferenceChange() {
         const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999);
@@ -49,6 +53,9 @@ export default class CenterPanel extends React.Component {
     onChannelChange() {
         this.setState({showPostFocus: ChannelStore.getPostMode() === ChannelStore.POST_MODE_FOCUS});
     }
+    onUserChange() {
+        this.setState({user: UserStore.getCurrentUser()});
+    }
     render() {
         const channel = ChannelStore.getCurrent();
         var handleClick = null;
@@ -108,7 +115,9 @@ export default class CenterPanel extends React.Component {
                         className='app__content'
                     >
                         <div id='channel-header'>
-                            <ChannelHeader/>
+                            <ChannelHeader
+                                user={this.state.user}
+                            />
                         </div>
                         {postsContainer}
                         {createPost}
-- 
cgit v1.2.3-1-g7c22

