From 238e48e4afb46a387d5632c552163b0b58ce7078 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 15 Mar 2017 12:02:08 +0000 Subject: [PATCH 1/2] Do routing to /register _onLoadCompleted _onLoadCompleted happens straight away because Lifecycle finishes loading the session instantly when registration parameters (client_secret etc.) are set. --- src/components/structures/MatrixChat.js | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 4f3c8fe7e5..48e7f40dca 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -696,6 +696,13 @@ module.exports = React.createClass({ _onLoadCompleted: function() { this.props.onLoadCompleted(); this.setState({loading: false}); + + // Show screens (like 'register') that need to be shown without onLoggedIn + // being called. 'register' needs to be routed here when the email confirmation + // link is clicked on. + if (['register'].indexOf(this.state.screenAfterLogin.screen) !== -1) { + this._showScreenAfterLogin(); + } }, /** @@ -751,6 +758,17 @@ module.exports = React.createClass({ logged_in: true, }); + if (teamToken) { + this._teamToken = teamToken; + dis.dispatch({action: 'view_home_page'}); + } else if (this._is_registered) { + dis.dispatch({action: 'view_user_settings'}); + } else { + this._showScreenAfterLogin(); + } + }, + + _showScreenAfterLogin: function() { // If screenAfterLogin is set, use that, then null it so that a second login will // result in view_home_page, _user_settings or _room_directory if (this.state.screenAfterLogin && this.state.screenAfterLogin.screen) { @@ -758,17 +776,8 @@ module.exports = React.createClass({ this.state.screenAfterLogin.screen, this.state.screenAfterLogin.params ); + this.notifyNewScreen(this.state.screenAfterLogin.screen); this.setState({screenAfterLogin: null}); - return; - } else { - this.setState({screen: undefined}); - } - - if (teamToken) { - this._teamToken = teamToken; - dis.dispatch({action: 'view_home_page'}); - } else if (this._is_registered) { - dis.dispatch({action: 'view_user_settings'}); } else { dis.dispatch({action: 'view_room_directory'}); } From 5330e47b3fd91df7833f1cc22bd96c7cea4d0130 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 15 Mar 2017 13:05:03 +0000 Subject: [PATCH 2/2] Add null check --- src/components/structures/MatrixChat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 48e7f40dca..2337d62fd8 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -700,7 +700,8 @@ module.exports = React.createClass({ // Show screens (like 'register') that need to be shown without onLoggedIn // being called. 'register' needs to be routed here when the email confirmation // link is clicked on. - if (['register'].indexOf(this.state.screenAfterLogin.screen) !== -1) { + if (this.state.screenAfterLogin && + ['register'].indexOf(this.state.screenAfterLogin.screen) !== -1) { this._showScreenAfterLogin(); } },