Handle manual hs urls better

pull/21833/head
Michael Telatynski 2020-12-08 10:58:16 +00:00
parent 603a1c8ffb
commit e896b009f1
3 changed files with 10 additions and 6 deletions

View File

@ -51,7 +51,8 @@ export default class ServerPickerDialog extends React.PureComponent<IProps, ISta
const { serverConfig } = this.props;
this.state = {
defaultChosen: serverConfig.isDefault,
otherHomeserver: serverConfig.isDefault ? "" : (serverConfig.hsName || serverConfig.hsUrl),
otherHomeserver: serverConfig.isDefault ? ""
: (serverConfig.static ? serverConfig.hsUrl : serverConfig.hsName || serverConfig.hsUrl),
};
}

View File

@ -67,7 +67,7 @@ const ServerPicker = ({ title, dialogTitle, serverConfig, onServerConfigChange }
</AccessibleButton>;
}
let serverName = serverConfig.hsName;
let serverName = serverConfig.static ? serverConfig.hsUrl : serverConfig.hsName;
if (serverConfig.hsNameIsDifferent) {
serverName = <TextWithTooltip class="mx_Login_underlinedServerName" tooltip={serverConfig.hsUrl}>
{serverConfig.hsName}

View File

@ -34,6 +34,8 @@ export class ValidatedServerConfig {
isUrl: string;
isDefault: boolean;
// when the server config is based on static URLs the hsName is not resolvable and things may wish to use hsUrl
static: boolean;
warning: string;
}
@ -161,7 +163,7 @@ export default class AutoDiscoveryUtils {
const url = new URL(homeserverUrl);
const serverName = url.hostname;
return AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, result, syntaxOnly);
return AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(serverName, result, syntaxOnly, true);
}
/**
@ -179,12 +181,12 @@ export default class AutoDiscoveryUtils {
* input.
* @param {string} serverName The domain name the AutoDiscovery result is for.
* @param {*} discoveryResult The AutoDiscovery result.
* @param {boolean} syntaxOnly If true, errors relating to liveliness of the servers will
* not be raised.
* @param {boolean} syntaxOnly If true, errors relating to liveliness of the servers will not be raised.
* @param {boolean} isStatic If true, then the discoveryResult was synthesised locally.
* @returns {Promise<ValidatedServerConfig>} Resolves to the validated configuration.
*/
static buildValidatedConfigFromDiscovery(
serverName: string, discoveryResult, syntaxOnly=false): ValidatedServerConfig {
serverName: string, discoveryResult, syntaxOnly=false, isStatic=false): ValidatedServerConfig {
if (!discoveryResult || !discoveryResult["m.homeserver"]) {
// This shouldn't happen without major misconfiguration, so we'll log a bit of information
// in the log so we can find this bit of codee but otherwise tell teh user "it broke".
@ -252,6 +254,7 @@ export default class AutoDiscoveryUtils {
isUrl: preferredIdentityUrl,
isDefault: false,
warning: hsResult.error,
static: isStatic,
});
}
}