From 19051083c353a669d51af028c7a6d14526e90642 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Wed, 25 May 2022 15:18:31 -0400 Subject: [PATCH 1/3] Show a dialog when Jitsi encounters an error --- src/i18n/strings/en_EN.json | 2 ++ src/stores/widgets/ElementWidgetActions.ts | 6 ++++++ src/stores/widgets/StopGapWidget.ts | 20 +++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7fbcac9569a..073c6f73c9a 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -831,6 +831,8 @@ "The person who invited you has already left.": "The person who invited you has already left.", "The person who invited you has already left, or their server is offline.": "The person who invited you has already left, or their server is offline.", "Failed to join": "Failed to join", + "Connection lost": "Connection lost", + "Jitsi meet encountered an error: %(message)s": "Jitsi meet encountered an error: %(message)s", "All rooms": "All rooms", "Home": "Home", "Favourites": "Favourites", diff --git a/src/stores/widgets/ElementWidgetActions.ts b/src/stores/widgets/ElementWidgetActions.ts index df82bf3b1f6..7ad41885be9 100644 --- a/src/stores/widgets/ElementWidgetActions.ts +++ b/src/stores/widgets/ElementWidgetActions.ts @@ -36,6 +36,12 @@ export enum ElementWidgetActions { ViewRoom = "io.element.view_room", } +export interface IHangupCallApiRequest extends IWidgetApiRequest { + data: { + errorMessage?: string; + }; +} + /** * @deprecated Use MSC2931 instead */ diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index 33395b79425..eed32e3e01c 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -37,6 +37,7 @@ import { MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/models/event"; import { logger } from "matrix-js-sdk/src/logger"; import { ClientEvent } from "matrix-js-sdk/src/client"; +import { _t } from "../../languageHandler"; import { StopGapWidgetDriver } from "./StopGapWidgetDriver"; import { WidgetMessagingStore } from "./WidgetMessagingStore"; import { RoomViewStore } from "../RoomViewStore"; @@ -50,7 +51,7 @@ import ActiveWidgetStore from "../ActiveWidgetStore"; import { objectShallowClone } from "../../utils/objects"; import defaultDispatcher from "../../dispatcher/dispatcher"; import { Action } from "../../dispatcher/actions"; -import { ElementWidgetActions, IViewRoomApiRequest } from "./ElementWidgetActions"; +import { ElementWidgetActions, IHangupCallApiRequest, IViewRoomApiRequest } from "./ElementWidgetActions"; import { ModalWidgetStore } from "../ModalWidgetStore"; import ThemeWatcher from "../../settings/watchers/ThemeWatcher"; import { getCustomTheme } from "../../theme"; @@ -60,6 +61,8 @@ import { getUserLanguage } from "../../languageHandler"; import { WidgetVariableCustomisations } from "../../customisations/WidgetVariables"; import { arrayFastClone } from "../../utils/arrays"; import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload"; +import Modal from "../../Modal"; +import ErrorDialog from "../../components/views/dialogs/ErrorDialog"; // TODO: Destroy all of this code @@ -367,6 +370,21 @@ export class StopGapWidget extends EventEmitter { }, ); } + + if (WidgetType.JITSI.matches(this.mockWidget.type)) { + this.messaging.on(`action:${ElementWidgetActions.HangupCall}`, + (ev: CustomEvent) => { + if (ev.detail.data?.errorMessage) { + Modal.createTrackedDialog("Connection lost", "", ErrorDialog, { + title: _t("Connection lost"), + description: _t("Jitsi meet encountered an error: %(message)s", { + message: ev.detail.data.errorMessage, + }), + }); + } + }, + ); + } } public async prepare(): Promise { From 881c4d7553e8bc76ae67a8862be42ef10b964862 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Wed, 25 May 2022 15:21:56 -0400 Subject: [PATCH 2/3] Capitalize 'Meet' --- src/i18n/strings/en_EN.json | 2 +- src/stores/widgets/StopGapWidget.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 073c6f73c9a..3d4d47463d7 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -832,7 +832,7 @@ "The person who invited you has already left, or their server is offline.": "The person who invited you has already left, or their server is offline.", "Failed to join": "Failed to join", "Connection lost": "Connection lost", - "Jitsi meet encountered an error: %(message)s": "Jitsi meet encountered an error: %(message)s", + "Jitsi Meet encountered an error: %(message)s": "Jitsi Meet encountered an error: %(message)s", "All rooms": "All rooms", "Home": "Home", "Favourites": "Favourites", diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index eed32e3e01c..eea268e0d3c 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -377,7 +377,7 @@ export class StopGapWidget extends EventEmitter { if (ev.detail.data?.errorMessage) { Modal.createTrackedDialog("Connection lost", "", ErrorDialog, { title: _t("Connection lost"), - description: _t("Jitsi meet encountered an error: %(message)s", { + description: _t("Jitsi Meet encountered an error: %(message)s", { message: ev.detail.data.errorMessage, }), }); From 72b0260f314a36744c8379d033ca8728606d27dd Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Thu, 26 May 2022 10:03:01 -0400 Subject: [PATCH 3/3] Revise copy to not mention Jitsi --- src/i18n/strings/en_EN.json | 2 +- src/stores/widgets/StopGapWidget.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3d4d47463d7..3aa40c62e6e 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -832,7 +832,7 @@ "The person who invited you has already left, or their server is offline.": "The person who invited you has already left, or their server is offline.", "Failed to join": "Failed to join", "Connection lost": "Connection lost", - "Jitsi Meet encountered an error: %(message)s": "Jitsi Meet encountered an error: %(message)s", + "You were disconnected from the call. (Error: %(message)s)": "You were disconnected from the call. (Error: %(message)s)", "All rooms": "All rooms", "Home": "Home", "Favourites": "Favourites", diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index eea268e0d3c..8d40a89ef87 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -377,7 +377,7 @@ export class StopGapWidget extends EventEmitter { if (ev.detail.data?.errorMessage) { Modal.createTrackedDialog("Connection lost", "", ErrorDialog, { title: _t("Connection lost"), - description: _t("Jitsi Meet encountered an error: %(message)s", { + description: _t("You were disconnected from the call. (Error: %(message)s)", { message: ev.detail.data.errorMessage, }), });