From 2fe555559af428e8e6c813d9f73c8038070da50e Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Wed, 8 Jan 2025 11:43:40 +0100 Subject: [PATCH] Rename `verification_required` into `set_up_encryption` --- .../tabs/user/EncryptionUserSettingsTab.tsx | 35 ++++++++++--------- .../user/EncryptionUserSettingsTab-test.tsx | 6 ++-- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx b/src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx index 1ec4e4182d..0825be0c83 100644 --- a/src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx @@ -23,25 +23,26 @@ import { SettingsSubheader } from "../../SettingsSubheader"; * The state in the encryption settings tab. * - "loading": We are checking if the device is verified. * - "main": The main panel with all the sections (Key storage, recovery, advanced). - * - "verification_required": The panel to show when the user needs to verify their session. + * - "set_up_encryption": The panel to show when the user is setting up their encryption. + * This happens when the user doesn't have cross-signing enabled. * - "change_recovery_key": The panel to show when the user is changing their recovery key. * This happens when the user has a key backup and the user clicks on "Change recovery key" button of the RecoveryPanel. * - "set_recovery_key": The panel to show when the user is setting up their recovery key. * This happens when the user doesn't have a key backup and the user clicks on "Set up recovery key" button of the RecoveryPanel. */ -type State = "loading" | "main" | "verification_required" | "change_recovery_key" | "set_recovery_key"; +type State = "loading" | "main" | "set_up_encryption" | "change_recovery_key" | "set_recovery_key"; export function EncryptionUserSettingsTab(): JSX.Element { const [state, setState] = useState("loading"); - const checkVerificationRequired = useVerificationRequired(setState); + const setUpEncryptionRequired = useSetUpEncryptionRequired(setState); let content: JSX.Element; switch (state) { case "loading": content = ; break; - case "verification_required": - content = ; + case "set_up_encryption": + content = ; break; case "main": content = ( @@ -72,31 +73,31 @@ export function EncryptionUserSettingsTab(): JSX.Element { } /** - * Hook to check if the user needs to verify their session. - * If the user needs to verify their session, the state will be set to "verification_required". - * If the user doesn't need to verify their session, the state will be set to "main". + * Hook to check if the user needs to set up their encryption for this session. + * If the user needs to set up the encryption, the state will be set to "set_up_encryption". + * Otherwise, the state will be set to "main". * @param setState */ -function useVerificationRequired(setState: (state: State) => void): () => Promise { +function useSetUpEncryptionRequired(setState: (state: State) => void): () => Promise { const matrixClient = useMatrixClientContext(); - const checkVerificationRequired = useCallback(async () => { + const setUpEncryptionRequired = useCallback(async () => { const crypto = matrixClient.getCrypto()!; const isCrossSigningReady = await crypto.isCrossSigningReady(); if (isCrossSigningReady) setState("main"); - else setState("verification_required"); + else setState("set_up_encryption"); }, [matrixClient, setState]); useEffect(() => { - checkVerificationRequired(); - }, [checkVerificationRequired]); + setUpEncryptionRequired(); + }, [setUpEncryptionRequired]); - return checkVerificationRequired; + return setUpEncryptionRequired; } -interface VerifySessionPanelProps { +interface SetUpEncryptionPanelProps { /** - * Callback to call when the user has finished verifying their session. + * Callback to call when the user has finished to set up the encryption. */ onFinish: () => void; } @@ -104,7 +105,7 @@ interface VerifySessionPanelProps { /** * Panel to show when the user needs to verify their session. */ -function VerifySessionPanel({ onFinish }: VerifySessionPanelProps): JSX.Element { +function SetUpEncryptionPanel({ onFinish }: SetUpEncryptionPanelProps): JSX.Element { return ( ", () => { return render(, withClientContextRenderOptions(matrixClient)); } - it("should display a loading state when the verification state is computed", () => { + it("should display a loading state when the encryption state is computed", () => { jest.spyOn(matrixClient.getCrypto()!, "isCrossSigningReady").mockImplementation(() => new Promise(() => {})); renderComponent(); expect(screen.getByLabelText("Loading…")).toBeInTheDocument(); }); - it("should display a verify button when the device is not verified", async () => { + it("should display a verify button when the encryption is not set up", async () => { const user = userEvent.setup(); jest.spyOn(matrixClient.getCrypto()!, "isCrossSigningReady").mockResolvedValue(false); @@ -64,7 +64,7 @@ describe("", () => { expect(spy).toHaveBeenCalled(); }); - it("should display the recovery panel when the device is verified", async () => { + it("should display the recovery panel when the encryption is set up", async () => { renderComponent(); await waitFor(() => expect(screen.getByText("Recovery")).toBeInTheDocument()); });