From ac2b8b874f2cc66e0eb6cc5b92539addc37aa050 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 27 Aug 2019 17:29:56 -0400 Subject: [PATCH] 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 --- src/components/views/auth/ServerConfig.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/views/auth/ServerConfig.js b/src/components/views/auth/ServerConfig.js index 467ba307d0..8197afd512 100644 --- a/src/components/views/auth/ServerConfig.js +++ b/src/components/views/auth/ServerConfig.js @@ -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; }