From baaa9f5dd2a6ec7ba631261a64ca4bc50c99ea77 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Wed, 30 Nov 2022 11:16:52 +0000 Subject: [PATCH] Show user an error if we fail to create a DM for verification (#9624) Related: https://github.com/vector-im/element-web/issues/23819 This is still pretty poor, but at least we don't get stuck with a 'verifying...' spinner that is a total failure. --- .../views/right_panel/EncryptionPanel.tsx | 17 +++++++++++++++-- src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/views/right_panel/EncryptionPanel.tsx b/src/components/views/right_panel/EncryptionPanel.tsx index d0d6c7bf5b..8e23668e08 100644 --- a/src/components/views/right_panel/EncryptionPanel.tsx +++ b/src/components/views/right_panel/EncryptionPanel.tsx @@ -111,8 +111,21 @@ const EncryptionPanel: React.FC = (props: IProps) => { const onStartVerification = useCallback(async () => { setRequesting(true); const cli = MatrixClientPeg.get(); - const roomId = await ensureDMExists(cli, member.userId); - const verificationRequest_ = await cli.requestVerificationDM(member.userId, roomId); + let verificationRequest_: VerificationRequest; + try { + const roomId = await ensureDMExists(cli, member.userId); + verificationRequest_ = await cli.requestVerificationDM(member.userId, roomId); + } catch (e) { + console.error("Error starting verification", e); + setRequesting(false); + + Modal.createDialog(ErrorDialog, { + headerImage: require("../../../../res/img/e2e/warning.svg").default, + title: _t("Error starting verification"), + description: _t("We were unable to start a chat with the other user."), + }); + return; + } setRequest(verificationRequest_); setPhase(verificationRequest_.phase); // Notify the RightPanelStore about this diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index c93e1a9626..4ee870bd72 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2152,6 +2152,8 @@ "The homeserver the user you're verifying is connected to": "The homeserver the user you're verifying is connected to", "Yours, or the other users' internet connection": "Yours, or the other users' internet connection", "Yours, or the other users' session": "Yours, or the other users' session", + "Error starting verification": "Error starting verification", + "We were unable to start a chat with the other user.": "We were unable to start a chat with the other user.", "Nothing pinned, yet": "Nothing pinned, yet", "If you have permissions, open the menu on any message and select Pin to stick them here.": "If you have permissions, open the menu on any message and select Pin to stick them here.", "Pinned messages": "Pinned messages",