From 1d77d2e0589ef38a201557798651a33e0b5f1623 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Mon, 23 Oct 2023 18:02:39 +0200 Subject: [PATCH 1/5] Add current version of the rust-sdk and vodozemac --- .../tabs/user/HelpUserSettingsTab.tsx | 20 +++++++++++++------ src/i18n/strings/en_EN.json | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx index 1b4ed9694ef..08d9889c94c 100644 --- a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx @@ -69,17 +69,23 @@ export default class HelpUserSettingsTab extends React.Component }); } - private getVersionInfo(): { appVersion: string; olmVersion: string } { + private getVersionInfo(): { appVersion: string; olmVersion: string | null; cryptoVersion: string | null } { const brand = SdkConfig.get().brand; const appVersion = this.state.appVersion || "unknown"; const olmVersionTuple = this.context.olmVersion; + + // New crypto version + const cryptoVersion = this.context.getCrypto()?.getVersion(); + + // XXXX: Remove when old crypto is gone const olmVersion = olmVersionTuple ? `${olmVersionTuple[0]}.${olmVersionTuple[1]}.${olmVersionTuple[2]}` : ""; return { appVersion: `${_t("setting|help_about|brand_version", { brand })} ${appVersion}`, - olmVersion: `${_t("setting|help_about|olm_version")} ${olmVersion}`, + olmVersion: olmVersionTuple ? `${_t("setting|help_about|olm_version")} ${olmVersion}` : null, + cryptoVersion: cryptoVersion ? `${_t("setting|help_about|crypto_version")} ${cryptoVersion}` : null, }; } @@ -220,8 +226,10 @@ export default class HelpUserSettingsTab extends React.Component } private getVersionTextToCopy = (): string => { - const { appVersion, olmVersion } = this.getVersionInfo(); - return `${appVersion}\n${olmVersion}`; + const { appVersion, olmVersion, cryptoVersion } = this.getVersionInfo(); + // olmVersion for old crypto, cryptoVersion for new crypto + // we can only have one or the other + return `${appVersion}\n${olmVersion ?? cryptoVersion}`; }; public render(): React.ReactNode { @@ -302,7 +310,7 @@ export default class HelpUserSettingsTab extends React.Component ); } - const { appVersion, olmVersion } = this.getVersionInfo(); + const { appVersion, olmVersion, cryptoVersion } = this.getVersionInfo(); return ( @@ -314,7 +322,7 @@ export default class HelpUserSettingsTab extends React.Component {appVersion}
- {olmVersion} + {olmVersion || cryptoVersion}
{updateButton} diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 50c1ad602a5..ed46fb83e10 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2383,6 +2383,7 @@ "brand_version": "%(brand)s version:", "chat_bot": "Chat with %(brand)s Bot", "clear_cache_reload": "Clear cache and reload", + "crypto_version": "Crypto version:", "help_link": "For help with using %(brand)s, click here.", "help_link_chat_bot": "For help with using %(brand)s, click here or start a chat with our bot using the button below.", "homeserver": "Homeserver is %(homeserverUrl)s", From 01440674ecbb3d71d84302d45183de8298c5abc3 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Tue, 24 Oct 2023 11:45:37 +0200 Subject: [PATCH 2/5] Use `CryptoAPI#getVersion` for old crypto --- .../tabs/user/HelpUserSettingsTab.tsx | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx index 08d9889c94c..9dc2106ad26 100644 --- a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx @@ -69,23 +69,14 @@ export default class HelpUserSettingsTab extends React.Component }); } - private getVersionInfo(): { appVersion: string; olmVersion: string | null; cryptoVersion: string | null } { + private getVersionInfo(): { appVersion: string; cryptoVersion: string } { const brand = SdkConfig.get().brand; const appVersion = this.state.appVersion || "unknown"; - const olmVersionTuple = this.context.olmVersion; - - // New crypto version - const cryptoVersion = this.context.getCrypto()?.getVersion(); - - // XXXX: Remove when old crypto is gone - const olmVersion = olmVersionTuple - ? `${olmVersionTuple[0]}.${olmVersionTuple[1]}.${olmVersionTuple[2]}` - : ""; + const cryptoVersion = this.context.getCrypto()?.getVersion() ?? ""; return { appVersion: `${_t("setting|help_about|brand_version", { brand })} ${appVersion}`, - olmVersion: olmVersionTuple ? `${_t("setting|help_about|olm_version")} ${olmVersion}` : null, - cryptoVersion: cryptoVersion ? `${_t("setting|help_about|crypto_version")} ${cryptoVersion}` : null, + cryptoVersion: `${_t("setting|help_about|crypto_version")} ${cryptoVersion}`, }; } @@ -226,10 +217,10 @@ export default class HelpUserSettingsTab extends React.Component } private getVersionTextToCopy = (): string => { - const { appVersion, olmVersion, cryptoVersion } = this.getVersionInfo(); + const { appVersion, cryptoVersion } = this.getVersionInfo(); // olmVersion for old crypto, cryptoVersion for new crypto // we can only have one or the other - return `${appVersion}\n${olmVersion ?? cryptoVersion}`; + return `${appVersion}\n${cryptoVersion}`; }; public render(): React.ReactNode { @@ -310,7 +301,7 @@ export default class HelpUserSettingsTab extends React.Component ); } - const { appVersion, olmVersion, cryptoVersion } = this.getVersionInfo(); + const { appVersion, cryptoVersion } = this.getVersionInfo(); return ( @@ -322,7 +313,7 @@ export default class HelpUserSettingsTab extends React.Component {appVersion}
- {olmVersion || cryptoVersion} + {cryptoVersion}
{updateButton} From b0105253daba7eed1fb8f151d2b95e9763797989 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Tue, 24 Oct 2023 11:54:30 +0200 Subject: [PATCH 3/5] Update i18n --- src/i18n/strings/en_EN.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ed46fb83e10..286f21b2b91 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2388,7 +2388,6 @@ "help_link_chat_bot": "For help with using %(brand)s, click here or start a chat with our bot using the button below.", "homeserver": "Homeserver is %(homeserverUrl)s", "identity_server": "Identity server is %(identityServerUrl)s", - "olm_version": "Olm version:", "title": "Help & About", "versions": "Versions" } From 0c9f56ec634f24131305e83baa020cc14c0974d7 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Tue, 24 Oct 2023 14:53:54 +0200 Subject: [PATCH 4/5] Fix test --- test/components/views/dialogs/UserSettingsDialog-test.tsx | 2 ++ test/test-utils/client.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/test/components/views/dialogs/UserSettingsDialog-test.tsx b/test/components/views/dialogs/UserSettingsDialog-test.tsx index 586288d2bdb..a2cd034ba36 100644 --- a/test/components/views/dialogs/UserSettingsDialog-test.tsx +++ b/test/components/views/dialogs/UserSettingsDialog-test.tsx @@ -28,6 +28,7 @@ import { mockClientMethodsUser, mockClientMethodsServer, mockPlatformPeg, + mockClientMethodsCrypto, } from "../../../test-utils"; import { UIFeature } from "../../../../src/settings/UIFeature"; import { SettingLevel } from "../../../../src/settings/SettingLevel"; @@ -70,6 +71,7 @@ describe("", () => { mockClient = getMockClientWithEventEmitter({ ...mockClientMethodsUser(userId), ...mockClientMethodsServer(), + ...mockClientMethodsCrypto(), }); sdkContext = new SdkContextClass(); sdkContext.client = mockClient; diff --git a/test/test-utils/client.ts b/test/test-utils/client.ts index 2bd0643a11a..9c00b22c3e1 100644 --- a/test/test-utils/client.ts +++ b/test/test-utils/client.ts @@ -168,5 +168,6 @@ export const mockClientMethodsCrypto = (): Partial< isCrossSigningReady: jest.fn().mockResolvedValue(true), isSecretStorageReady: jest.fn(), getSessionBackupPrivateKey: jest.fn(), + getVersion: jest.fn().mockReturnValue("Version 0"), }), }); From d2a8cccc1178e2d750155430ffea02ecd81e96c4 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Wed, 25 Oct 2023 16:12:46 +0200 Subject: [PATCH 5/5] Remove wrong comment --- src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx index 9dc2106ad26..85b04cf7a91 100644 --- a/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/HelpUserSettingsTab.tsx @@ -218,8 +218,6 @@ export default class HelpUserSettingsTab extends React.Component private getVersionTextToCopy = (): string => { const { appVersion, cryptoVersion } = this.getVersionInfo(); - // olmVersion for old crypto, cryptoVersion for new crypto - // we can only have one or the other return `${appVersion}\n${cryptoVersion}`; };