From 96080f2ccce68c67d33cc1416f1c71c074cb9321 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 10 Sep 2020 14:06:13 +0100 Subject: [PATCH] Prompt to remove the jitsi widget when pressing the call button If there's already one in the room. We threw up an error message anyway telling you there was already a jitsi widget, so just add a button to end the call. --- src/CallHandler.js | 17 ++++++++++++----- src/i18n/strings/en_EN.json | 5 +++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index 27e8e34e16..e6552c13fd 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -69,6 +69,8 @@ import {WidgetType} from "./widgets/WidgetType"; import {SettingLevel} from "./settings/SettingLevel"; import {base32} from "rfc4648"; +import QuestionDialog from "./components/views/dialogs/QuestionDialog"; + global.mxCalls = { //room_id: MatrixCall }; @@ -202,7 +204,6 @@ function _setCallState(call, roomId, status) { function _showICEFallbackPrompt() { const cli = MatrixClientPeg.get(); - const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); const code = sub => {sub}; Modal.createTrackedDialog('No TURN servers', '', QuestionDialog, { title: _t("Call failed due to misconfigured server"), @@ -380,11 +381,17 @@ async function _startCallApp(roomId, type) { "Refusing to start conference call widget in " + roomId + " a conference call widget is already present", ); - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); - Modal.createTrackedDialog('Already have Jitsi Widget', '', ErrorDialog, { - title: _t('Call in Progress'), - description: _t('A call is already in progress!'), + Modal.createTrackedDialog('Already have Jitsi Widget', '', QuestionDialog, { + title: _t('End Call'), + description: _t('Remove the group call from the room?'), + button: _t('End Call'), + cancelButton: _t('Cancel'), + onFinished: (endCall) => { + if (endCall) { + WidgetUtils.setRoomWidget(roomId, currentJitsiWidgets[0].getContent()['id']); + } + }, }); return; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 77cd8ef661..53f1850925 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -50,7 +50,9 @@ "You cannot place a call with yourself.": "You cannot place a call with yourself.", "Call in Progress": "Call in Progress", "A call is currently being placed!": "A call is currently being placed!", - "A call is already in progress!": "A call is already in progress!", + "End Call": "End Call", + "Remove the group call from the room?": "Remove the group call from the room?", + "Cancel": "Cancel", "Permission Required": "Permission Required", "You do not have permission to start a conference call in this room": "You do not have permission to start a conference call in this room", "Replying With Files": "Replying With Files", @@ -140,7 +142,6 @@ "Cancel entering passphrase?": "Cancel entering passphrase?", "Are you sure you want to cancel entering passphrase?": "Are you sure you want to cancel entering passphrase?", "Go Back": "Go Back", - "Cancel": "Cancel", "Setting up keys": "Setting up keys", "Messages": "Messages", "Actions": "Actions",