delint CallHandler

This commit is contained in:
David Baker 2018-06-18 16:00:42 +01:00
parent 8cf17a66e5
commit e1e60cb147
2 changed files with 72 additions and 61 deletions

View file

@ -4,7 +4,6 @@ src/autocomplete/AutocompleteProvider.js
src/autocomplete/Autocompleter.js src/autocomplete/Autocompleter.js
src/autocomplete/EmojiProvider.js src/autocomplete/EmojiProvider.js
src/autocomplete/UserProvider.js src/autocomplete/UserProvider.js
src/CallHandler.js
src/component-index.js src/component-index.js
src/components/structures/BottomLeftMenu.js src/components/structures/BottomLeftMenu.js
src/components/structures/CompatibilityPage.js src/components/structures/CompatibilityPage.js

View file

@ -124,7 +124,7 @@ function _setCallListeners(call) {
description: _t( description: _t(
"There are unknown devices in this room: "+ "There are unknown devices in this room: "+
"if you proceed without verifying them, it will be "+ "if you proceed without verifying them, it will be "+
"possible for someone to eavesdrop on your call." "possible for someone to eavesdrop on your call.",
), ),
button: _t('Review Devices'), button: _t('Review Devices'),
onFinished: function(confirmed) { onFinished: function(confirmed) {
@ -247,50 +247,52 @@ function _onAction(payload) {
switch (payload.action) { switch (payload.action) {
case 'place_call': case 'place_call':
if (module.exports.getAnyActiveCall()) { {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); if (module.exports.getAnyActiveCall()) {
Modal.createTrackedDialog('Call Handler', 'Existing Call', ErrorDialog, { const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
title: _t('Existing Call'), Modal.createTrackedDialog('Call Handler', 'Existing Call', ErrorDialog, {
description: _t('You are already in a call.'), title: _t('Existing Call'),
}); description: _t('You are already in a call.'),
return; // don't allow >1 call to be placed. });
} return; // don't allow >1 call to be placed.
}
// 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"); 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.'),
}); });
return; return;
} }
var room = MatrixClientPeg.get().getRoom(payload.room_id); const room = MatrixClientPeg.get().getRoom(payload.room_id);
if (!room) { if (!room) {
console.error("Room %s does not exist.", payload.room_id); console.error("Room %s does not exist.", payload.room_id);
return; return;
} }
var members = room.getJoinedMembers(); const members = room.getJoinedMembers();
if (members.length <= 1) { if (members.length <= 1) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); 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.'),
}); });
return; return;
} else if (members.length === 2) { } else if (members.length === 2) {
console.log("Place %s call in %s", payload.type, payload.room_id); console.log("Place %s call in %s", payload.type, payload.room_id);
const call = Matrix.createNewMatrixCall(MatrixClientPeg.get(), payload.room_id); const call = Matrix.createNewMatrixCall(MatrixClientPeg.get(), payload.room_id);
placeCall(call); placeCall(call);
} else { // > 2 } else { // > 2
dis.dispatch({ dis.dispatch({
action: "place_conference_call", action: "place_conference_call",
room_id: payload.room_id, room_id: payload.room_id,
type: payload.type, type: payload.type,
remote_element: payload.remote_element, remote_element: payload.remote_element,
local_element: payload.local_element, local_element: payload.local_element,
}); });
}
} }
break; break;
case 'place_conference_call': case 'place_conference_call':
@ -338,10 +340,18 @@ function _onAction(payload) {
}, function(err) { }, function(err) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
console.error("Conference call failed: " + err); console.error("Conference call failed: " + err);
Modal.createTrackedDialog('Call Handler', 'Failed to set up conference call', ErrorDialog, { Modal.createTrackedDialog(
title: _t('Failed to set up conference call'), 'Call Handler',
description: _t('Conference call failed.') + ' ' + ((err && err.message) ? err.message : ''), 'Failed to set up conference call',
}); ErrorDialog,
{
title: _t('Failed to set up conference call'),
description: (
_t('Conference call failed.') +
' ' + ((err && err.message) ? err.message : '')
),
},
);
}); });
} }
}, },
@ -350,22 +360,24 @@ function _onAction(payload) {
} }
break; break;
case 'incoming_call': case 'incoming_call':
if (module.exports.getAnyActiveCall()) { {
// ignore multiple incoming calls. in future, we may want a line-1/line-2 setup. if (module.exports.getAnyActiveCall()) {
// we avoid rejecting with "busy" in case the user wants to answer it on a different device. // ignore multiple incoming calls. in future, we may want a line-1/line-2 setup.
// in future we could signal a "local busy" as a warning to the caller. // we avoid rejecting with "busy" in case the user wants to answer it on a different device.
// see https://github.com/vector-im/vector-web/issues/1964 // in future we could signal a "local busy" as a warning to the caller.
return; // see https://github.com/vector-im/vector-web/issues/1964
} return;
}
// if the runtime env doesn't do VoIP, stop here. // if the runtime env doesn't do VoIP, stop here.
if (!MatrixClientPeg.get().supportsVoip()) { if (!MatrixClientPeg.get().supportsVoip()) {
return; return;
} }
var call = payload.call; const call = payload.call;
_setCallListeners(call); _setCallListeners(call);
_setCallState(call, call.roomId, "ringing"); _setCallState(call, call.roomId, "ringing");
}
break; break;
case 'hangup': case 'hangup':
if (!calls[payload.room_id]) { if (!calls[payload.room_id]) {