diff options
Diffstat (limited to 'webapp/components/logged_in.jsx')
-rw-r--r-- | webapp/components/logged_in.jsx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/webapp/components/logged_in.jsx b/webapp/components/logged_in.jsx index 53db501bf..f7a6be647 100644 --- a/webapp/components/logged_in.jsx +++ b/webapp/components/logged_in.jsx @@ -14,6 +14,7 @@ const TutorialSteps = Constants.TutorialSteps; const Preferences = Constants.Preferences; import ErrorBar from 'components/error_bar.jsx'; import * as Websockets from 'action_creators/websocket_actions.jsx'; +import LoadingScreen from 'components/loading_screen.jsx'; import {browserHistory} from 'react-router'; @@ -44,6 +45,13 @@ export default class LoggedIn extends React.Component { super(params); this.onUserChanged = this.onUserChanged.bind(this); + + this.state = { + user: null + }; + } + isValidState() { + return this.state.user != null; } onUserChanged() { // Grab the current user @@ -75,6 +83,8 @@ export default class LoggedIn extends React.Component { if (tutorialStep <= TutorialSteps.INTRO_SCREENS) { browserHistory.push(Utils.getTeamURLFromAddressBar() + '/tutorial'); } + + this.setState({user}); } componentWillMount() { // Emit view action @@ -186,6 +196,8 @@ export default class LoggedIn extends React.Component { Websockets.close(); UserStore.removeChangeListener(this.onUserChanged); + Utils.resetTheme(); + $('body').off('click.userpopover'); $('body').off('mouseenter mouseleave', '.post'); $('body').off('mouseenter mouseleave', '.post.post--comment.same--root'); @@ -195,11 +207,18 @@ export default class LoggedIn extends React.Component { $(window).off('keydown.preventBackspace'); } render() { + if (!this.isValidState()) { + return <LoadingScreen/>; + } + let content = []; if (this.props.children) { content = this.props.children; } else { content.push( + this.props.navbar + ); + content.push( this.props.sidebar ); content.push( @@ -247,8 +266,9 @@ LoggedIn.defaultProps = { }; LoggedIn.propTypes = { - children: React.PropTypes.object, - sidebar: React.PropTypes.object, - center: React.PropTypes.object, + children: React.PropTypes.arrayOf(React.PropTypes.element), + navbar: React.PropTypes.element, + sidebar: React.PropTypes.element, + center: React.PropTypes.element, params: React.PropTypes.object }; |