diff options
Diffstat (limited to 'webapp/components/channel_view.jsx')
-rw-r--r-- | webapp/components/channel_view.jsx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/webapp/components/channel_view.jsx b/webapp/components/channel_view.jsx index 6c2157ffd..4a5ac8969 100644 --- a/webapp/components/channel_view.jsx +++ b/webapp/components/channel_view.jsx @@ -31,18 +31,22 @@ export default class ChannelView extends React.Component { this.state = this.getStateFromStores(props); } + getStateFromStores() { return { channelId: ChannelStore.getCurrentId(), tutorialStep: PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999) }; } + isStateValid() { return this.state.channelId !== ''; } + updateState() { this.setState(this.getStateFromStores(this.props)); } + componentDidMount() { ChannelStore.addChangeListener(this.updateState); @@ -53,14 +57,17 @@ export default class ChannelView extends React.Component { $('body').addClass('browser--ie'); } } + componentWillUnmount() { ChannelStore.removeChangeListener(this.updateState); $('body').removeClass('app__body'); } + componentWillReceiveProps(nextProps) { this.setState(this.getStateFromStores(nextProps)); } + shouldComponentUpdate(nextProps, nextState) { if (!Utils.areObjectsEqual(nextProps.params, this.props.params)) { return true; @@ -72,6 +79,11 @@ export default class ChannelView extends React.Component { return false; } + + getChannelView = () => { + return this.refs.channelView; + } + render() { if (this.state.tutorialStep <= TutorialSteps.INTRO_SCREENS) { return (<TutorialView/>); @@ -79,6 +91,7 @@ export default class ChannelView extends React.Component { return ( <div + ref='channelView' id='app-content' className='app__content' > @@ -93,7 +106,7 @@ export default class ChannelView extends React.Component { className='post-create__container' id='post-create' > - <CreatePost/> + <CreatePost getChannelView={this.getChannelView}/> </div> </div> ); |