Move error dialog to the new check

So we just check for an existing call in one place where it doesn't race
pull/21833/head
David Baker 2021-09-02 15:51:44 +01:00
parent edf6d13818
commit cd8e7e3076
1 changed files with 11 additions and 9 deletions

View File

@ -754,7 +754,15 @@ export default class CallHandler extends EventEmitter {
console.log("Current turn creds expire in " + timeUntilTurnCresExpire + " ms"); console.log("Current turn creds expire in " + timeUntilTurnCresExpire + " ms");
const call = MatrixClientPeg.get().createCall(mappedRoomId); const call = MatrixClientPeg.get().createCall(mappedRoomId);
this.addCallForRoom(roomId, call); try {
this.addCallForRoom(roomId, call);
} catch (e) {
Modal.createTrackedDialog('Call Handler', 'Existing Call with user', ErrorDialog, {
title: _t('Already in call'),
description: _t("You're already in a call with this person."),
});
return;
}
if (transferee) { if (transferee) {
this.transferees[call.callId] = transferee; this.transferees[call.callId] = transferee;
} }
@ -806,14 +814,8 @@ export default class CallHandler extends EventEmitter {
return; return;
} }
console.log("getting call for room " + room.roomId); // We leave the check for whether there's already a call in this room until later,
if (this.getCallForRoom(room.roomId)) { // otherwise it can race.
Modal.createTrackedDialog('Call Handler', 'Existing Call with user', ErrorDialog, {
title: _t('Already in call'),
description: _t("You're already in a call with this person."),
});
return;
}
const members = room.getJoinedMembers(); const members = room.getJoinedMembers();
if (members.length <= 1) { if (members.length <= 1) {