From 213e284edfeba1c3e7b5da64f309360fd6506e41 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 21 Jun 2016 11:05:37 +0100 Subject: [PATCH 1/2] Fix https://github.com/vector-im/vector-web/issues/1679 --- src/components/structures/MatrixChat.js | 30 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 1973fedbcd..4c59d16474 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -108,10 +108,14 @@ module.exports = React.createClass({ return window.localStorage.getItem("mx_hs_url"); } else { - return this.props.config.default_hs_url || "https://matrix.org"; + return this.getDefaultHsUrl(); } }, + getDefaultHsUrl() { + return this.props.config.default_hs_url || "https://matrix.org"; + }, + getFallbackHsUrl: function() { return this.props.config.fallback_hs_url; }, @@ -126,10 +130,14 @@ module.exports = React.createClass({ return window.localStorage.getItem("mx_is_url"); } else { - return this.props.config.default_is_url || "https://vector.im" + return this.getDefaultIsUrl(); } }, + getDefaultIsUrl() { + return this.props.config.default_is_url || "https://vector.im"; + }, + componentWillMount: function() { this.favicon = new Favico({animation: 'none'}); }, @@ -151,8 +159,8 @@ module.exports = React.createClass({ this.onLoggedIn({ userId: this.props.startingQueryParams.guest_user_id, accessToken: this.props.startingQueryParams.guest_access_token, - homeserverUrl: this.props.config.default_hs_url, - identityServerUrl: this.props.config.default_is_url, + homeserverUrl: this.getDefaultHsUrl(), + identityServerUrl: this.getDefaultIsUrl(), guest: true }); } @@ -1109,8 +1117,8 @@ module.exports = React.createClass({ email={this.props.startingQueryParams.email} username={this.state.upgradeUsername} guestAccessToken={this.state.guestAccessToken} - defaultHsUrl={this.props.config.default_hs_url} - defaultIsUrl={this.props.config.default_is_url} + defaultHsUrl={this.getDefaultHsUrl()} + defaultIsUrl={this.getDefaultIsUrl()} brand={this.props.config.brand} customHsUrl={this.getCurrentHsUrl()} customIsUrl={this.getCurrentIsUrl()} @@ -1124,8 +1132,8 @@ module.exports = React.createClass({ } else if (this.state.screen == 'forgot_password') { return ( ); From d3265ab9707db33a0d8c92d017c100d3cde6a261 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 21 Jun 2016 17:46:55 +0100 Subject: [PATCH 2/2] Redundant getDeafultHs() This now can never be falsey so no point checking it --- src/components/structures/MatrixChat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 4c59d16474..24ebd95f60 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1150,7 +1150,7 @@ module.exports = React.createClass({ customIsUrl={this.getCurrentIsUrl()} fallbackHsUrl={this.getFallbackHsUrl()} onForgotPasswordClick={this.onForgotPasswordClick} - onLoginAsGuestClick={this.props.enableGuest && this.props.config && this.getDefaultHsUrl() ? this._registerAsGuest.bind(this, true) : undefined} + onLoginAsGuestClick={this.props.enableGuest && this.props.config && this._registerAsGuest.bind(this, true)} onCancelClick={ this.state.guestCreds ? this.onReturnToGuestClick : null } /> );