From 8cbddfcf28891ece5a6fbdd8c7c7a93f7f2a49c0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 29 Sep 2016 17:23:07 +0100 Subject: [PATCH] Fix version going blank after logging in Don't use replaceState in MatrixClient: there's lots of stuff in MatrixClient's state now (including the app version) so replacing the entire state doesn't really make sense (and also blows away all of the nice defaults we set in getInitialState). Instead, setState of the things we actually care about wherever we used replaceState. Also add a couple of state variables to getInitialState that were missing. Fixes https://github.com/vector-im/vector-web/issues/2322 --- src/components/structures/MatrixChat.js | 42 +++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 47d316e966..d9e4dc9c30 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -105,6 +105,9 @@ module.exports = React.createClass({ version: null, newVersion: null, + + upgradeUsername: null, + guestAccessToken: null, }; return s; }, @@ -261,13 +264,20 @@ module.exports = React.createClass({ newState.register_is_url = payload.params.is_url; newState.register_id_sid = payload.params.sid; } - this.replaceState(newState); + this.setState(newState); this.notifyNewScreen('register'); break; case 'start_login': if (this.state.logged_in) return; - this.replaceState({ + this.setState({ screen: 'login', + currentRoomAlias: null, + currentRoomId: null, + viewUserId: null, + logged_in: false, + ready: false, + upgradeUsername: null, + guestAccessToken: null, }); this.notifyNewScreen('login'); break; @@ -279,8 +289,13 @@ module.exports = React.createClass({ case 'start_upgrade_registration': // stash our guest creds so we can backout if needed this.guestCreds = MatrixClientPeg.getCredentials(); - this.replaceState({ + this.setState({ screen: "register", + currentRoomAlias: null, + currentRoomId: null, + viewUserId: null, + logged_in: false, + ready: false, upgradeUsername: MatrixClientPeg.get().getUserIdLocalpart(), guestAccessToken: MatrixClientPeg.get().getAccessToken(), }); @@ -288,8 +303,15 @@ module.exports = React.createClass({ break; case 'start_password_recovery': if (this.state.logged_in) return; - this.replaceState({ - screen: 'forgot_password' + this.setState({ + screen: 'forgot_password', + currentRoomAlias: null, + currentRoomId: null, + viewUserId: null, + logged_in: false, + ready: false, + upgradeUsername: null, + guestAccessToken: null, }); this.notifyNewScreen('forgot_password'); break; @@ -595,9 +617,17 @@ module.exports = React.createClass({ */ _onLoggedOut: function() { this.notifyNewScreen('login'); - this.replaceState({ + this.setState({ + screen: undefined, + currentRoomAlias: null, + currentRoomId: null, + viewUserId: null, logged_in: false, ready: false, + upgradeUsername: null, + guestAccessToken: null, + collapse_lhs: false, + collapse_rhs: false, }); },