Don't prompt to remove jitsi widget if the user don't have permission

pull/21833/head
David Baker 2020-09-11 12:20:32 +01:00
parent 96080f2ccc
commit e54d4e665f
2 changed files with 20 additions and 21 deletions

View File

@ -70,6 +70,7 @@ import {SettingLevel} from "./settings/SettingLevel";
import {base32} from "rfc4648"; import {base32} from "rfc4648";
import QuestionDialog from "./components/views/dialogs/QuestionDialog"; import QuestionDialog from "./components/views/dialogs/QuestionDialog";
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
global.mxCalls = { global.mxCalls = {
//room_id: MatrixCall //room_id: MatrixCall
@ -133,7 +134,6 @@ function _setCallListeners(call) {
return; return;
} }
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call Failed', '', ErrorDialog, { Modal.createTrackedDialog('Call Failed', '', ErrorDialog, {
title: _t('Call Failed'), title: _t('Call Failed'),
description: err.message, description: err.message,
@ -162,7 +162,6 @@ function _setCallListeners(call) {
_setCallState(call, call.roomId, "busy"); _setCallState(call, call.roomId, "busy");
pause("ringbackAudio"); pause("ringbackAudio");
play("busyAudio"); play("busyAudio");
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call Handler', 'Call Timeout', ErrorDialog, { Modal.createTrackedDialog('Call Handler', 'Call Timeout', ErrorDialog, {
title: _t('Call Timeout'), title: _t('Call Timeout'),
description: _t('The remote side failed to pick up') + '.', description: _t('The remote side failed to pick up') + '.',
@ -246,7 +245,6 @@ function _onAction(payload) {
if (screenCapErrorString) { if (screenCapErrorString) {
_setCallState(undefined, newCall.roomId, "ended"); _setCallState(undefined, newCall.roomId, "ended");
console.log("Can't capture screen: " + screenCapErrorString); console.log("Can't capture screen: " + screenCapErrorString);
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call Handler', 'Unable to capture screen', ErrorDialog, { Modal.createTrackedDialog('Call Handler', 'Unable to capture screen', ErrorDialog, {
title: _t('Unable to capture screen'), title: _t('Unable to capture screen'),
description: screenCapErrorString, description: screenCapErrorString,
@ -266,7 +264,6 @@ function _onAction(payload) {
case 'place_call': case 'place_call':
{ {
if (callHandler.getAnyActiveCall()) { if (callHandler.getAnyActiveCall()) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call Handler', 'Existing Call', ErrorDialog, { Modal.createTrackedDialog('Call Handler', 'Existing Call', ErrorDialog, {
title: _t('Existing Call'), title: _t('Existing Call'),
description: _t('You are already in a call.'), description: _t('You are already in a call.'),
@ -276,7 +273,6 @@ function _onAction(payload) {
// if the runtime env doesn't do VoIP, whine. // if the runtime env doesn't do VoIP, whine.
if (!MatrixClientPeg.get().supportsVoip()) { if (!MatrixClientPeg.get().supportsVoip()) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call Handler', 'VoIP is unsupported', ErrorDialog, { Modal.createTrackedDialog('Call Handler', 'VoIP is unsupported', ErrorDialog, {
title: _t('VoIP is unsupported'), title: _t('VoIP is unsupported'),
description: _t('You cannot place VoIP calls in this browser.'), description: _t('You cannot place VoIP calls in this browser.'),
@ -292,7 +288,6 @@ function _onAction(payload) {
const members = room.getJoinedMembers(); const members = room.getJoinedMembers();
if (members.length <= 1) { if (members.length <= 1) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call Handler', 'Cannot place call with self', ErrorDialog, { Modal.createTrackedDialog('Call Handler', 'Cannot place call with self', ErrorDialog, {
description: _t('You cannot place a call with yourself.'), description: _t('You cannot place a call with yourself.'),
}); });
@ -367,8 +362,6 @@ async function _startCallApp(roomId, type) {
const currentJitsiWidgets = WidgetUtils.getRoomWidgetsOfType(room, WidgetType.JITSI); const currentJitsiWidgets = WidgetUtils.getRoomWidgetsOfType(room, WidgetType.JITSI);
if (WidgetEchoStore.roomHasPendingWidgetsOfType(roomId, currentJitsiWidgets, WidgetType.JITSI)) { if (WidgetEchoStore.roomHasPendingWidgetsOfType(roomId, currentJitsiWidgets, WidgetType.JITSI)) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call already in progress', '', ErrorDialog, { Modal.createTrackedDialog('Call already in progress', '', ErrorDialog, {
title: _t('Call in Progress'), title: _t('Call in Progress'),
description: _t('A call is currently being placed!'), description: _t('A call is currently being placed!'),
@ -382,17 +375,24 @@ async function _startCallApp(roomId, type) {
" a conference call widget is already present", " a conference call widget is already present",
); );
Modal.createTrackedDialog('Already have Jitsi Widget', '', QuestionDialog, { if (WidgetUtils.canUserModifyWidgets(roomId)) {
title: _t('End Call'), Modal.createTrackedDialog('Already have Jitsi Widget', '', QuestionDialog, {
description: _t('Remove the group call from the room?'), title: _t('End Call'),
button: _t('End Call'), description: _t('Remove the group call from the room?'),
cancelButton: _t('Cancel'), button: _t('End Call'),
onFinished: (endCall) => { cancelButton: _t('Cancel'),
if (endCall) { onFinished: (endCall) => {
WidgetUtils.setRoomWidget(roomId, currentJitsiWidgets[0].getContent()['id']); if (endCall) {
} WidgetUtils.setRoomWidget(roomId, currentJitsiWidgets[0].getContent()['id']);
}, }
}); },
});
} else {
Modal.createTrackedDialog('Already have Jitsi Widget', '', ErrorDialog, {
title: _t('Call in Progress'),
description: _t("You don't have permission to remove the call from the room"),
});
}
return; return;
} }
@ -436,8 +436,6 @@ async function _startCallApp(roomId, type) {
console.log('Jitsi widget added'); console.log('Jitsi widget added');
}).catch((e) => { }).catch((e) => {
if (e.errcode === 'M_FORBIDDEN') { if (e.errcode === 'M_FORBIDDEN') {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Call Failed', '', ErrorDialog, { Modal.createTrackedDialog('Call Failed', '', ErrorDialog, {
title: _t('Permission Required'), title: _t('Permission Required'),
description: _t("You do not have permission to start a conference call in this room"), description: _t("You do not have permission to start a conference call in this room"),

View File

@ -53,6 +53,7 @@
"End Call": "End Call", "End Call": "End Call",
"Remove the group call from the room?": "Remove the group call from the room?", "Remove the group call from the room?": "Remove the group call from the room?",
"Cancel": "Cancel", "Cancel": "Cancel",
"You don't have permission to remove the call from the room": "You don't have permission to remove the call from the room",
"Permission Required": "Permission Required", "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", "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", "Replying With Files": "Replying With Files",