Validate server URLs on blur instead of change
This commit is contained in:
parent
f60cfe5cb2
commit
36d162cb25
4 changed files with 49 additions and 34 deletions
|
@ -571,7 +571,7 @@ module.exports = React.createClass({
|
||||||
defaultHsUrl={this.props.defaultHsUrl}
|
defaultHsUrl={this.props.defaultHsUrl}
|
||||||
defaultIsUrl={this.props.defaultIsUrl}
|
defaultIsUrl={this.props.defaultIsUrl}
|
||||||
onServerConfigChange={this.onServerConfigChange}
|
onServerConfigChange={this.onServerConfigChange}
|
||||||
delayTimeMs={1000}
|
delayTimeMs={250}
|
||||||
/>;
|
/>;
|
||||||
break;
|
break;
|
||||||
case ServerType.ADVANCED:
|
case ServerType.ADVANCED:
|
||||||
|
@ -581,7 +581,7 @@ module.exports = React.createClass({
|
||||||
defaultHsUrl={this.props.defaultHsUrl}
|
defaultHsUrl={this.props.defaultHsUrl}
|
||||||
defaultIsUrl={this.props.defaultIsUrl}
|
defaultIsUrl={this.props.defaultIsUrl}
|
||||||
onServerConfigChange={this.onServerConfigChange}
|
onServerConfigChange={this.onServerConfigChange}
|
||||||
delayTimeMs={1000}
|
delayTimeMs={250}
|
||||||
/>;
|
/>;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,9 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_replaceClient: async function() {
|
_replaceClient: async function() {
|
||||||
|
this.setState({
|
||||||
|
errorText: null,
|
||||||
|
});
|
||||||
this._matrixClient = Matrix.createClient({
|
this._matrixClient = Matrix.createClient({
|
||||||
baseUrl: this.state.hsUrl,
|
baseUrl: this.state.hsUrl,
|
||||||
idBaseUrl: this.state.isUrl,
|
idBaseUrl: this.state.isUrl,
|
||||||
|
@ -390,7 +393,7 @@ module.exports = React.createClass({
|
||||||
defaultHsUrl={this.props.defaultHsUrl}
|
defaultHsUrl={this.props.defaultHsUrl}
|
||||||
defaultIsUrl={this.props.defaultIsUrl}
|
defaultIsUrl={this.props.defaultIsUrl}
|
||||||
onServerConfigChange={this.onServerConfigChange}
|
onServerConfigChange={this.onServerConfigChange}
|
||||||
delayTimeMs={1000}
|
delayTimeMs={250}
|
||||||
/>;
|
/>;
|
||||||
break;
|
break;
|
||||||
case ServerType.ADVANCED:
|
case ServerType.ADVANCED:
|
||||||
|
@ -400,7 +403,7 @@ module.exports = React.createClass({
|
||||||
defaultHsUrl={this.props.defaultHsUrl}
|
defaultHsUrl={this.props.defaultHsUrl}
|
||||||
defaultIsUrl={this.props.defaultIsUrl}
|
defaultIsUrl={this.props.defaultIsUrl}
|
||||||
onServerConfigChange={this.onServerConfigChange}
|
onServerConfigChange={this.onServerConfigChange}
|
||||||
delayTimeMs={1000}
|
delayTimeMs={250}
|
||||||
/>;
|
/>;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,8 +77,7 @@ export default class ModularServerConfig extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onHomeserverChanged = (ev) => {
|
onHomeserverBlur = (ev) => {
|
||||||
this.setState({hsUrl: ev.target.value}, () => {
|
|
||||||
this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => {
|
this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => {
|
||||||
let hsUrl = this.state.hsUrl.trim().replace(/\/$/, "");
|
let hsUrl = this.state.hsUrl.trim().replace(/\/$/, "");
|
||||||
if (hsUrl === "") hsUrl = this.props.defaultHsUrl;
|
if (hsUrl === "") hsUrl = this.props.defaultHsUrl;
|
||||||
|
@ -87,7 +86,11 @@ export default class ModularServerConfig extends React.PureComponent {
|
||||||
isUrl: this.props.defaultIsUrl,
|
isUrl: this.props.defaultIsUrl,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
onHomeserverChange = (ev) => {
|
||||||
|
const hsUrl = ev.target.value;
|
||||||
|
this.setState({ hsUrl });
|
||||||
}
|
}
|
||||||
|
|
||||||
_waitThenInvoke(existingTimeoutId, fn) {
|
_waitThenInvoke(existingTimeoutId, fn) {
|
||||||
|
@ -117,7 +120,8 @@ export default class ModularServerConfig extends React.PureComponent {
|
||||||
label={_t("Server Name")}
|
label={_t("Server Name")}
|
||||||
placeholder={this.props.defaultHsUrl}
|
placeholder={this.props.defaultHsUrl}
|
||||||
value={this.state.hsUrl}
|
value={this.state.hsUrl}
|
||||||
onChange={this.onHomeserverChanged}
|
onBlur={this.onHomeserverBlur}
|
||||||
|
onChange={this.onHomeserverChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -76,8 +76,7 @@ export default class ServerConfig extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onHomeserverChanged = (ev) => {
|
onHomeserverBlur = (ev) => {
|
||||||
this.setState({hsUrl: ev.target.value}, () => {
|
|
||||||
this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => {
|
this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, () => {
|
||||||
let hsUrl = this.state.hsUrl.trim().replace(/\/$/, "");
|
let hsUrl = this.state.hsUrl.trim().replace(/\/$/, "");
|
||||||
if (hsUrl === "") hsUrl = this.props.defaultHsUrl;
|
if (hsUrl === "") hsUrl = this.props.defaultHsUrl;
|
||||||
|
@ -86,11 +85,14 @@ export default class ServerConfig extends React.PureComponent {
|
||||||
isUrl: this.state.isUrl,
|
isUrl: this.state.isUrl,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onIdentityServerChanged = (ev) => {
|
onHomeserverChange = (ev) => {
|
||||||
this.setState({isUrl: ev.target.value}, () => {
|
const hsUrl = ev.target.value;
|
||||||
|
this.setState({ hsUrl });
|
||||||
|
}
|
||||||
|
|
||||||
|
onIdentityServerBlur = (ev) => {
|
||||||
this._isTimeoutId = this._waitThenInvoke(this._isTimeoutId, () => {
|
this._isTimeoutId = this._waitThenInvoke(this._isTimeoutId, () => {
|
||||||
let isUrl = this.state.isUrl.trim().replace(/\/$/, "");
|
let isUrl = this.state.isUrl.trim().replace(/\/$/, "");
|
||||||
if (isUrl === "") isUrl = this.props.defaultIsUrl;
|
if (isUrl === "") isUrl = this.props.defaultIsUrl;
|
||||||
|
@ -99,7 +101,11 @@ export default class ServerConfig extends React.PureComponent {
|
||||||
isUrl: this.state.isUrl,
|
isUrl: this.state.isUrl,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
onIdentityServerChange = (ev) => {
|
||||||
|
const isUrl = ev.target.value;
|
||||||
|
this.setState({ isUrl });
|
||||||
}
|
}
|
||||||
|
|
||||||
_waitThenInvoke(existingTimeoutId, fn) {
|
_waitThenInvoke(existingTimeoutId, fn) {
|
||||||
|
@ -130,13 +136,15 @@ export default class ServerConfig extends React.PureComponent {
|
||||||
label={_t("Homeserver URL")}
|
label={_t("Homeserver URL")}
|
||||||
placeholder={this.props.defaultHsUrl}
|
placeholder={this.props.defaultHsUrl}
|
||||||
value={this.state.hsUrl}
|
value={this.state.hsUrl}
|
||||||
onChange={this.onHomeserverChanged}
|
onBlur={this.onHomeserverBlur}
|
||||||
|
onChange={this.onHomeserverChange}
|
||||||
/>
|
/>
|
||||||
<Field id="mx_ServerConfig_isUrl"
|
<Field id="mx_ServerConfig_isUrl"
|
||||||
label={_t("Identity Server URL")}
|
label={_t("Identity Server URL")}
|
||||||
placeholder={this.props.defaultIsUrl}
|
placeholder={this.props.defaultIsUrl}
|
||||||
value={this.state.isUrl}
|
value={this.state.isUrl}
|
||||||
onChange={this.onIdentityServerChanged}
|
onBlur={this.onIdentityServerBlur}
|
||||||
|
onChange={this.onIdentityServerChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue