From fc37b8c6a3b2722e042ccfefc777209d9765025b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 26 Apr 2023 18:05:47 +0100 Subject: [PATCH 1/2] Fix start_sso not working with guests disabled --- src/components/structures/MatrixChat.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 07590446a3a..d4cbdd53316 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -161,7 +161,7 @@ interface IScreen { interface IProps { config: IConfigOptions; - serverConfig?: ValidatedServerConfig; + serverConfig?: ValidatedServerConfig; // only seemingly used for unit tests onNewScreen: (screen: string, replaceLast: boolean) => void; enableGuest?: boolean; // the queryParams extracted from the [real] query-string of the URI @@ -472,7 +472,7 @@ export default class MatrixChat extends React.PureComponent { }, 1000); private getFallbackHsUrl(): string | undefined { - if (this.props.serverConfig?.isDefault) { + if (this.getServerProperties().serverConfig?.isDefault) { return this.props.config.fallback_hs_url; } } @@ -1774,7 +1774,7 @@ export default class MatrixChat extends React.PureComponent { } else if (screen === "start_sso" || screen === "start_cas") { let cli = MatrixClientPeg.get(); if (!cli) { - const { hsUrl, isUrl } = this.props.serverConfig; + const { hsUrl, isUrl } = this.getServerProperties().serverConfig; cli = createClient({ baseUrl: hsUrl, idBaseUrl: isUrl, From 2fc64c778e24a5842369722c45003e73c3d9b822 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 26 Apr 2023 18:06:52 +0100 Subject: [PATCH 2/2] Remove confusing prop --- src/components/structures/MatrixChat.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index d4cbdd53316..cad98d821a7 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -161,7 +161,6 @@ interface IScreen { interface IProps { config: IConfigOptions; - serverConfig?: ValidatedServerConfig; // only seemingly used for unit tests onNewScreen: (screen: string, replaceLast: boolean) => void; enableGuest?: boolean; // the queryParams extracted from the [real] query-string of the URI @@ -478,9 +477,7 @@ export default class MatrixChat extends React.PureComponent { } private getServerProperties(): { serverConfig: ValidatedServerConfig } { - let props = this.state.serverConfig; - if (!props) props = this.props.serverConfig; // for unit tests - if (!props) props = SdkConfig.get("validated_server_config")!; + const props = this.state.serverConfig || SdkConfig.get("validated_server_config")!; return { serverConfig: props }; }