summaryrefslogtreecommitdiffstats
path: root/webapp/components/root.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-04-01 09:26:28 -0400
committerChristopher Speller <crspeller@gmail.com>2016-04-01 11:53:53 -0400
commit35b63caafc912dae2200b5b6497ad059189c5048 (patch)
tree8757f7ab512dab029759e99f7d565618a5a22f8d /webapp/components/root.jsx
parent36f611fac48536f26770357de8d5b6767bd46d2f (diff)
downloadchat-35b63caafc912dae2200b5b6497ad059189c5048.tar.gz
chat-35b63caafc912dae2200b5b6497ad059189c5048.tar.bz2
chat-35b63caafc912dae2200b5b6497ad059189c5048.zip
Fixing signup flow. Better root redirect. Fixes back buttons.
Diffstat (limited to 'webapp/components/root.jsx')
-rw-r--r--webapp/components/root.jsx23
1 files changed, 22 insertions, 1 deletions
diff --git a/webapp/components/root.jsx b/webapp/components/root.jsx
index 3b85b23fd..59364d085 100644
--- a/webapp/components/root.jsx
+++ b/webapp/components/root.jsx
@@ -3,6 +3,7 @@
import $ from 'jquery';
import * as GlobalActions from 'action_creators/global_actions.jsx';
+import * as Client from 'utils/client.jsx';
import BrowserStore from 'stores/browser_store.jsx';
import LocalizationStore from 'stores/localization_store.jsx';
@@ -12,6 +13,8 @@ import React from 'react';
import FastClick from 'fastclick';
+import {browserHistory} from 'react-router';
+
export default class Root extends React.Component {
constructor(props) {
super(props);
@@ -21,10 +24,25 @@ export default class Root extends React.Component {
};
this.localizationChanged = this.localizationChanged.bind(this);
+ this.redirectIfNecessary = this.redirectIfNecessary.bind(this);
}
localizationChanged() {
this.setState({locale: LocalizationStore.getLocale(), translations: LocalizationStore.getTranslations()});
}
+ redirectIfNecessary(props) {
+ if (props.location.pathname === '/') {
+ Client.getMeLoggedIn((data) => {
+ if (!data || data.logged_in === 'false') {
+ browserHistory.push('/signup_team');
+ } else {
+ browserHistory.push('/' + data.team_name + '/channels/town-square');
+ }
+ });
+ }
+ }
+ componentWillReceiveProps(newProps) {
+ this.redirectIfNecessary(newProps);
+ }
componentWillMount() {
// Setup localization listener
LocalizationStore.addChangeListener(this.localizationChanged);
@@ -70,12 +88,15 @@ export default class Root extends React.Component {
// Get our localizaiton
GlobalActions.loadBrowserLocale();
+
+ // Redirect if Necessary
+ this.redirectIfNecessary(this.props);
}
componentWillUnmount() {
LocalizationStore.removeChangeListener(this.localizationChanged);
}
render() {
- if (this.state.translations == null) {
+ if (this.state.translations == null || this.props.children == null) {
return <div/>;
}