diff --git a/src/components/structures/auth/E2eSetup.tsx b/src/components/structures/auth/E2eSetup.tsx index 80a135fe19..265905db10 100644 --- a/src/components/structures/auth/E2eSetup.tsx +++ b/src/components/structures/auth/E2eSetup.tsx @@ -11,7 +11,7 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix"; import AuthPage from "../../views/auth/AuthPage"; import CompleteSecurityBody from "../../views/auth/CompleteSecurityBody"; -import CreateCrossSigningDialog from "../../views/dialogs/security/CreateCrossSigningDialog"; +import { InitialCryptoSetupDialog } from "../../views/dialogs/security/InitialCryptoSetupDialog"; interface IProps { matrixClient: MatrixClient; @@ -25,7 +25,7 @@ export default class E2eSetup extends React.Component { return ( - = ({ matrixClient, accountPassword, tokenLogin, onFinished }) => { +export const InitialCryptoSetupDialog: React.FC = ({ + matrixClient, + accountPassword, + tokenLogin, + onFinished, +}) => { const [error, setError] = useState(false); - const bootstrapCrossSigning = useCallback(async () => { + const doSetup = useCallback(async () => { const cryptoApi = matrixClient.getCrypto(); if (!cryptoApi) return; @@ -40,6 +45,7 @@ const CreateCrossSigningDialog: React.FC = ({ matrixClient, accountPasswo try { await createCrossSigning(matrixClient, tokenLogin, accountPassword); + onFinished(true); } catch (e) { if (tokenLogin) { @@ -58,8 +64,8 @@ const CreateCrossSigningDialog: React.FC = ({ matrixClient, accountPasswo }, [onFinished]); useEffect(() => { - bootstrapCrossSigning(); - }, [bootstrapCrossSigning]); + doSetup(); + }, [doSetup]); let content; if (error) { @@ -69,7 +75,7 @@ const CreateCrossSigningDialog: React.FC = ({ matrixClient, accountPasswo
@@ -95,5 +101,3 @@ const CreateCrossSigningDialog: React.FC = ({ matrixClient, accountPasswo ); }; - -export default CreateCrossSigningDialog; diff --git a/test/components/views/dialogs/security/CreateCrossSigningDialog-test.tsx b/test/components/views/dialogs/security/InitialCryptoSetupDialog-test.tsx similarity index 91% rename from test/components/views/dialogs/security/CreateCrossSigningDialog-test.tsx rename to test/components/views/dialogs/security/InitialCryptoSetupDialog-test.tsx index 3e5dc4eb94..4d3d495a38 100644 --- a/test/components/views/dialogs/security/CreateCrossSigningDialog-test.tsx +++ b/test/components/views/dialogs/security/InitialCryptoSetupDialog-test.tsx @@ -12,14 +12,14 @@ import { mocked } from "jest-mock"; import { MatrixClient } from "matrix-js-sdk/src/matrix"; import { createCrossSigning } from "../../../../../src/CreateCrossSigning"; -import CreateCrossSigningDialog from "../../../../../src/components/views/dialogs/security/CreateCrossSigningDialog"; +import { InitialCryptoSetupDialog } from "../../../../../src/components/views/dialogs/security/InitialCryptoSetupDialog"; import { createTestClient } from "../../../../test-utils"; jest.mock("../../../../../src/CreateCrossSigning", () => ({ createCrossSigning: jest.fn(), })); -describe("CreateCrossSigningDialog", () => { +describe("InitialCryptoSetupDialog", () => { let client: MatrixClient; let createCrossSigningResolve: () => void; let createCrossSigningReject: (e: Error) => void; @@ -43,7 +43,7 @@ describe("CreateCrossSigningDialog", () => { const onFinished = jest.fn(); render( - { it("should display an error if createCrossSigning fails", async () => { render( - { const onFinished = jest.fn(); render( - { const onFinished = jest.fn(); render( - { it("should retry when the retry button is clicked", async () => { render( -