From e5b55db1dbb944322808dd8024c4b36ebbaffaf3 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Tue, 29 Oct 2024 13:28:41 +0100 Subject: [PATCH] Remove upgrade encryption in `DeviceListener` and `SetupEncryptionToast` (#28299) * Remove upgrade encryption in `DeviceListener` and `SetupEncryptionToast` * Update comments to `2 different toasts` --- src/DeviceListener.ts | 24 +++++++++--------------- src/i18n/strings/en_EN.json | 1 - src/toasts/SetupEncryptionToast.ts | 7 ------- test/unit-tests/DeviceListener-test.ts | 4 ++-- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/DeviceListener.ts b/src/DeviceListener.ts index ea812d7379..3cf153fc58 100644 --- a/src/DeviceListener.ts +++ b/src/DeviceListener.ts @@ -292,27 +292,21 @@ export default class DeviceListener { await crypto.getUserDeviceInfo([cli.getSafeUserId()]); // cross signing isn't enabled - nag to enable it - // There are 3 different toasts for: + // There are 2 different toasts for: if (!(await crypto.getCrossSigningKeyId()) && (await crypto.userHasCrossSigningKeys())) { // Cross-signing on account but this device doesn't trust the master key (verify this session) showSetupEncryptionToast(SetupKind.VERIFY_THIS_SESSION); this.checkKeyBackupStatus(); } else { - const backupInfo = await this.getKeyBackupInfo(); - if (backupInfo) { - // No cross-signing on account but key backup available (upgrade encryption) - showSetupEncryptionToast(SetupKind.UPGRADE_ENCRYPTION); + // No cross-signing or key backup on account (set up encryption) + await cli.waitForClientWellKnown(); + if (isSecureBackupRequired(cli) && isLoggedIn()) { + // If we're meant to set up, and Secure Backup is required, + // trigger the flow directly without a toast once logged in. + hideSetupEncryptionToast(); + accessSecretStorage(); } else { - // No cross-signing or key backup on account (set up encryption) - await cli.waitForClientWellKnown(); - if (isSecureBackupRequired(cli) && isLoggedIn()) { - // If we're meant to set up, and Secure Backup is required, - // trigger the flow directly without a toast once logged in. - hideSetupEncryptionToast(); - accessSecretStorage(); - } else { - showSetupEncryptionToast(SetupKind.SET_UP_ENCRYPTION); - } + showSetupEncryptionToast(SetupKind.SET_UP_ENCRYPTION); } } } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7ba141c784..41c4396ff3 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -930,7 +930,6 @@ }, "unable_to_setup_keys_error": "Unable to set up keys", "unsupported": "This client does not support end-to-end encryption.", - "upgrade_toast_title": "Encryption upgrade available", "verification": { "accepting": "Accepting…", "after_new_login": { diff --git a/src/toasts/SetupEncryptionToast.ts b/src/toasts/SetupEncryptionToast.ts index 39408ba7f7..0dd54bb18f 100644 --- a/src/toasts/SetupEncryptionToast.ts +++ b/src/toasts/SetupEncryptionToast.ts @@ -23,8 +23,6 @@ const getTitle = (kind: Kind): string => { switch (kind) { case Kind.SET_UP_ENCRYPTION: return _t("encryption|set_up_toast_title"); - case Kind.UPGRADE_ENCRYPTION: - return _t("encryption|upgrade_toast_title"); case Kind.VERIFY_THIS_SESSION: return _t("encryption|verify_toast_title"); } @@ -33,7 +31,6 @@ const getTitle = (kind: Kind): string => { const getIcon = (kind: Kind): string => { switch (kind) { case Kind.SET_UP_ENCRYPTION: - case Kind.UPGRADE_ENCRYPTION: return "secure_backup"; case Kind.VERIFY_THIS_SESSION: return "verification_warning"; @@ -44,8 +41,6 @@ const getSetupCaption = (kind: Kind): string => { switch (kind) { case Kind.SET_UP_ENCRYPTION: return _t("action|continue"); - case Kind.UPGRADE_ENCRYPTION: - return _t("action|upgrade"); case Kind.VERIFY_THIS_SESSION: return _t("action|verify"); } @@ -54,7 +49,6 @@ const getSetupCaption = (kind: Kind): string => { const getDescription = (kind: Kind): string => { switch (kind) { case Kind.SET_UP_ENCRYPTION: - case Kind.UPGRADE_ENCRYPTION: return _t("encryption|set_up_toast_description"); case Kind.VERIFY_THIS_SESSION: return _t("encryption|verify_toast_description"); @@ -63,7 +57,6 @@ const getDescription = (kind: Kind): string => { export enum Kind { SET_UP_ENCRYPTION = "set_up_encryption", - UPGRADE_ENCRYPTION = "upgrade_encryption", VERIFY_THIS_SESSION = "verify_this_session", } diff --git a/test/unit-tests/DeviceListener-test.ts b/test/unit-tests/DeviceListener-test.ts index 64761d7da1..0f3bb68254 100644 --- a/test/unit-tests/DeviceListener-test.ts +++ b/test/unit-tests/DeviceListener-test.ts @@ -351,13 +351,13 @@ describe("DeviceListener", () => { mockCrypto!.getCrossSigningKeyId.mockResolvedValue("abc"); }); - it("shows upgrade encryption toast when user has a key backup available", async () => { + it("shows set up encryption toast when user has a key backup available", async () => { // non falsy response mockClient!.getKeyBackupVersion.mockResolvedValue({} as unknown as KeyBackupInfo); await createAndStart(); expect(SetupEncryptionToast.showToast).toHaveBeenCalledWith( - SetupEncryptionToast.Kind.UPGRADE_ENCRYPTION, + SetupEncryptionToast.Kind.SET_UP_ENCRYPTION, ); }); });