diff --git a/src/components/structures/auth/Login.js b/src/components/structures/auth/Login.js index 8d846112b6..fc33d9b54f 100644 --- a/src/components/structures/auth/Login.js +++ b/src/components/structures/auth/Login.js @@ -571,7 +571,7 @@ module.exports = React.createClass({ defaultHsUrl={this.props.defaultHsUrl} defaultIsUrl={this.props.defaultIsUrl} onServerConfigChange={this.onServerConfigChange} - delayTimeMs={1000} + delayTimeMs={250} />; break; case ServerType.ADVANCED: @@ -581,7 +581,7 @@ module.exports = React.createClass({ defaultHsUrl={this.props.defaultHsUrl} defaultIsUrl={this.props.defaultIsUrl} onServerConfigChange={this.onServerConfigChange} - delayTimeMs={1000} + delayTimeMs={250} />; break; } diff --git a/src/components/structures/auth/Registration.js b/src/components/structures/auth/Registration.js index ca2d7716a9..2a2d0eb4d6 100644 --- a/src/components/structures/auth/Registration.js +++ b/src/components/structures/auth/Registration.js @@ -151,6 +151,9 @@ module.exports = React.createClass({ }, _replaceClient: async function() { + this.setState({ + errorText: null, + }); this._matrixClient = Matrix.createClient({ baseUrl: this.state.hsUrl, idBaseUrl: this.state.isUrl, @@ -390,7 +393,7 @@ module.exports = React.createClass({ defaultHsUrl={this.props.defaultHsUrl} defaultIsUrl={this.props.defaultIsUrl} onServerConfigChange={this.onServerConfigChange} - delayTimeMs={1000} + delayTimeMs={250} />; break; case ServerType.ADVANCED: @@ -400,7 +403,7 @@ module.exports = React.createClass({ defaultHsUrl={this.props.defaultHsUrl} defaultIsUrl={this.props.defaultIsUrl} onServerConfigChange={this.onServerConfigChange} - delayTimeMs={1000} + delayTimeMs={250} />; break; } diff --git a/src/components/views/auth/ModularServerConfig.js b/src/components/views/auth/ModularServerConfig.js index 34b600dd40..61bfba1125 100644 --- a/src/components/views/auth/ModularServerConfig.js +++ b/src/components/views/auth/ModularServerConfig.js @@ -77,19 +77,22 @@ export default class ModularServerConfig extends React.PureComponent { }); } - onHomeserverChanged = (ev) => { - this.setState({hsUrl: ev.target.value}, () => { - this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => { - let hsUrl = this.state.hsUrl.trim().replace(/\/$/, ""); - if (hsUrl === "") hsUrl = this.props.defaultHsUrl; - this.props.onServerConfigChange({ - hsUrl: this.state.hsUrl, - isUrl: this.props.defaultIsUrl, - }); + onHomeserverBlur = (ev) => { + this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => { + let hsUrl = this.state.hsUrl.trim().replace(/\/$/, ""); + if (hsUrl === "") hsUrl = this.props.defaultHsUrl; + this.props.onServerConfigChange({ + hsUrl: this.state.hsUrl, + isUrl: this.props.defaultIsUrl, }); }); } + onHomeserverChange = (ev) => { + const hsUrl = ev.target.value; + this.setState({ hsUrl }); + } + _waitThenInvoke(existingTimeoutId, fn) { if (existingTimeoutId) { clearTimeout(existingTimeoutId); @@ -117,7 +120,8 @@ export default class ModularServerConfig extends React.PureComponent { label={_t("Server Name")} placeholder={this.props.defaultHsUrl} value={this.state.hsUrl} - onChange={this.onHomeserverChanged} + onBlur={this.onHomeserverBlur} + onChange={this.onHomeserverChange} /> diff --git a/src/components/views/auth/ServerConfig.js b/src/components/views/auth/ServerConfig.js index fb35104e49..d90e2c36b5 100644 --- a/src/components/views/auth/ServerConfig.js +++ b/src/components/views/auth/ServerConfig.js @@ -76,32 +76,38 @@ export default class ServerConfig extends React.PureComponent { }); } - onHomeserverChanged = (ev) => { - this.setState({hsUrl: ev.target.value}, () => { - this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => { - let hsUrl = this.state.hsUrl.trim().replace(/\/$/, ""); - if (hsUrl === "") hsUrl = this.props.defaultHsUrl; - this.props.onServerConfigChange({ - hsUrl: this.state.hsUrl, - isUrl: this.state.isUrl, - }); + onHomeserverBlur = (ev) => { + this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => { + let hsUrl = this.state.hsUrl.trim().replace(/\/$/, ""); + if (hsUrl === "") hsUrl = this.props.defaultHsUrl; + this.props.onServerConfigChange({ + hsUrl: this.state.hsUrl, + isUrl: this.state.isUrl, }); }); } - onIdentityServerChanged = (ev) => { - this.setState({isUrl: ev.target.value}, () => { - this._isTimeoutId = this._waitThenInvoke(this._isTimeoutId, () => { - let isUrl = this.state.isUrl.trim().replace(/\/$/, ""); - if (isUrl === "") isUrl = this.props.defaultIsUrl; - this.props.onServerConfigChange({ - hsUrl: this.state.hsUrl, - isUrl: this.state.isUrl, - }); + onHomeserverChange = (ev) => { + const hsUrl = ev.target.value; + this.setState({ hsUrl }); + } + + onIdentityServerBlur = (ev) => { + this._isTimeoutId = this._waitThenInvoke(this._isTimeoutId, () => { + let isUrl = this.state.isUrl.trim().replace(/\/$/, ""); + if (isUrl === "") isUrl = this.props.defaultIsUrl; + this.props.onServerConfigChange({ + hsUrl: this.state.hsUrl, + isUrl: this.state.isUrl, }); }); } + onIdentityServerChange = (ev) => { + const isUrl = ev.target.value; + this.setState({ isUrl }); + } + _waitThenInvoke(existingTimeoutId, fn) { if (existingTimeoutId) { clearTimeout(existingTimeoutId); @@ -130,13 +136,15 @@ export default class ServerConfig extends React.PureComponent { label={_t("Homeserver URL")} placeholder={this.props.defaultHsUrl} value={this.state.hsUrl} - onChange={this.onHomeserverChanged} + onBlur={this.onHomeserverBlur} + onChange={this.onHomeserverChange} />