Merge pull request #318 from matrix-org/dbkr/fix_default_hs

Fix https://github.com/vector-im/vector-web/issues/1679
This commit is contained in:
Richard van der Hoff 2016-06-21 17:55:27 +01:00 committed by GitHub
commit 2ddfccdab3

View file

@ -108,10 +108,14 @@ module.exports = React.createClass({
return window.localStorage.getItem("mx_hs_url"); return window.localStorage.getItem("mx_hs_url");
} }
else { 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() { getFallbackHsUrl: function() {
return this.props.config.fallback_hs_url; return this.props.config.fallback_hs_url;
}, },
@ -126,10 +130,14 @@ module.exports = React.createClass({
return window.localStorage.getItem("mx_is_url"); return window.localStorage.getItem("mx_is_url");
} }
else { 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() { componentWillMount: function() {
this.favicon = new Favico({animation: 'none'}); this.favicon = new Favico({animation: 'none'});
}, },
@ -151,8 +159,8 @@ module.exports = React.createClass({
this.onLoggedIn({ this.onLoggedIn({
userId: this.props.startingQueryParams.guest_user_id, userId: this.props.startingQueryParams.guest_user_id,
accessToken: this.props.startingQueryParams.guest_access_token, accessToken: this.props.startingQueryParams.guest_access_token,
homeserverUrl: this.props.config.default_hs_url, homeserverUrl: this.getDefaultHsUrl(),
identityServerUrl: this.props.config.default_is_url, identityServerUrl: this.getDefaultIsUrl(),
guest: true guest: true
}); });
} }
@ -1113,8 +1121,8 @@ module.exports = React.createClass({
email={this.props.startingQueryParams.email} email={this.props.startingQueryParams.email}
username={this.state.upgradeUsername} username={this.state.upgradeUsername}
guestAccessToken={this.state.guestAccessToken} guestAccessToken={this.state.guestAccessToken}
defaultHsUrl={this.props.config.default_hs_url} defaultHsUrl={this.getDefaultHsUrl()}
defaultIsUrl={this.props.config.default_is_url} defaultIsUrl={this.getDefaultIsUrl()}
brand={this.props.config.brand} brand={this.props.config.brand}
customHsUrl={this.getCurrentHsUrl()} customHsUrl={this.getCurrentHsUrl()}
customIsUrl={this.getCurrentIsUrl()} customIsUrl={this.getCurrentIsUrl()}
@ -1128,8 +1136,8 @@ module.exports = React.createClass({
} else if (this.state.screen == 'forgot_password') { } else if (this.state.screen == 'forgot_password') {
return ( return (
<ForgotPassword <ForgotPassword
defaultHsUrl={this.props.config.default_hs_url} defaultHsUrl={this.getDefaultHsUrl()}
defaultIsUrl={this.props.config.default_is_url} defaultIsUrl={this.getDefaultIsUrl()}
customHsUrl={this.getCurrentHsUrl()} customHsUrl={this.getCurrentHsUrl()}
customIsUrl={this.getCurrentIsUrl()} customIsUrl={this.getCurrentIsUrl()}
onComplete={this.onLoginClick} onComplete={this.onLoginClick}
@ -1140,13 +1148,13 @@ module.exports = React.createClass({
<Login <Login
onLoggedIn={this.onLoggedIn} onLoggedIn={this.onLoggedIn}
onRegisterClick={this.onRegisterClick} onRegisterClick={this.onRegisterClick}
defaultHsUrl={this.props.config.default_hs_url} defaultHsUrl={this.getDefaultHsUrl()}
defaultIsUrl={this.props.config.default_is_url} defaultIsUrl={this.getDefaultIsUrl()}
customHsUrl={this.getCurrentHsUrl()} customHsUrl={this.getCurrentHsUrl()}
customIsUrl={this.getCurrentIsUrl()} customIsUrl={this.getCurrentIsUrl()}
fallbackHsUrl={this.getFallbackHsUrl()} fallbackHsUrl={this.getFallbackHsUrl()}
onForgotPasswordClick={this.onForgotPasswordClick} onForgotPasswordClick={this.onForgotPasswordClick}
onLoginAsGuestClick={this.props.enableGuest && this.props.config && this.props.config.default_hs_url ? 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 } onCancelClick={ this.state.guestCreds ? this.onReturnToGuestClick : null }
/> />
); );