diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-02-23 14:34:06 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-02-23 14:34:06 -0500 |
commit | 0031c6fd1a4df621cbecfd2a2b3efe9a40cd49ce (patch) | |
tree | 2afcb0888267be4cf59df2d0e8f5085d6aacccb0 /web/react/components/center_panel.jsx | |
parent | 11093ddb51a70622287aac20108be6c6aa2eb76d (diff) | |
parent | 1f049af2b7ea41a5e1e79a8263e10fa58f186c8d (diff) | |
download | chat-0031c6fd1a4df621cbecfd2a2b3efe9a40cd49ce.tar.gz chat-0031c6fd1a4df621cbecfd2a2b3efe9a40cd49ce.tar.bz2 chat-0031c6fd1a4df621cbecfd2a2b3efe9a40cd49ce.zip |
Merge pull request #2229 from mattermost/plt-1770
PLT-1770 Refactor store listeners out of highly used components
Diffstat (limited to 'web/react/components/center_panel.jsx')
-rw-r--r-- | web/react/components/center_panel.jsx | 13 |
1 files changed, 11 insertions, 2 deletions
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} |