Improve identifiers and code readability

pull/21833/head
Michael Telatynski 2020-12-09 11:14:06 +00:00
parent e896b009f1
commit 5be65a525d
3 changed files with 16 additions and 7 deletions

View File

@ -49,10 +49,19 @@ export default class ServerPickerDialog extends React.PureComponent<IProps, ISta
const config = SdkConfig.get(); const config = SdkConfig.get();
this.defaultServer = config["validated_server_config"] as ValidatedServerConfig; this.defaultServer = config["validated_server_config"] as ValidatedServerConfig;
const { serverConfig } = this.props; const { serverConfig } = this.props;
let otherHomeserver = "";
if (!serverConfig.isDefault) {
if (serverConfig.isNameResolvable && serverConfig.hsName) {
otherHomeserver = serverConfig.hsName;
} else {
otherHomeserver = serverConfig.hsUrl;
}
}
this.state = { this.state = {
defaultChosen: serverConfig.isDefault, defaultChosen: serverConfig.isDefault,
otherHomeserver: serverConfig.isDefault ? "" otherHomeserver,
: (serverConfig.static ? serverConfig.hsUrl : serverConfig.hsName || serverConfig.hsUrl),
}; };
} }

View File

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

View File

@ -35,7 +35,7 @@ export class ValidatedServerConfig {
isDefault: boolean; isDefault: boolean;
// when the server config is based on static URLs the hsName is not resolvable and things may wish to use hsUrl // when the server config is based on static URLs the hsName is not resolvable and things may wish to use hsUrl
static: boolean; isNameResolvable: boolean;
warning: string; warning: string;
} }
@ -182,11 +182,11 @@ export default class AutoDiscoveryUtils {
* @param {string} serverName The domain name the AutoDiscovery result is for. * @param {string} serverName The domain name the AutoDiscovery result is for.
* @param {*} discoveryResult The AutoDiscovery result. * @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. * @param {boolean} isSynthetic If true, then the discoveryResult was synthesised locally.
* @returns {Promise<ValidatedServerConfig>} Resolves to the validated configuration. * @returns {Promise<ValidatedServerConfig>} Resolves to the validated configuration.
*/ */
static buildValidatedConfigFromDiscovery( static buildValidatedConfigFromDiscovery(
serverName: string, discoveryResult, syntaxOnly=false, isStatic=false): ValidatedServerConfig { serverName: string, discoveryResult, syntaxOnly=false, isSynthetic=false): ValidatedServerConfig {
if (!discoveryResult || !discoveryResult["m.homeserver"]) { if (!discoveryResult || !discoveryResult["m.homeserver"]) {
// This shouldn't happen without major misconfiguration, so we'll log a bit of information // 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". // in the log so we can find this bit of codee but otherwise tell teh user "it broke".
@ -254,7 +254,7 @@ export default class AutoDiscoveryUtils {
isUrl: preferredIdentityUrl, isUrl: preferredIdentityUrl,
isDefault: false, isDefault: false,
warning: hsResult.error, warning: hsResult.error,
static: isStatic, isNameResolvable: !isSynthetic,
}); });
} }
} }