Don't infinite loop on server change

ServerConfig assumed that the state was already correct when
checking the given urls against the default, but that is not
neccessarily the case (eg. the validation can return a different
url to what the user entered). This would cause an infinite loop
because it would keep firing onServerConfigChange to change to
the desired URLs but the state would never change.

Fixes part of https://github.com/vector-im/riot-web/issues/10666
This commit is contained in:
David Baker 2019-08-27 17:29:56 -04:00
parent 8e799b7136
commit ac2b8b874f

View file

@ -82,7 +82,12 @@ export default class ServerConfig extends React.PureComponent {
// Always try and use the defaults first
const defaultConfig: ValidatedServerConfig = SdkConfig.get()["validated_server_config"];
if (defaultConfig.hsUrl === hsUrl && defaultConfig.isUrl === isUrl) {
this.setState({busy: false, errorText: ""});
this.setState({
hsUrl: defaultConfig.hsUrl,
isUrl: defaultConfig.isUrl,
busy: false,
errorText: "",
});
this.props.onServerConfigChange(defaultConfig);
return defaultConfig;
}