mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 20:38:55 +03:00
Fix the call preview when not in same room as the call
Classic failure of an ES6 map also being a regular object :( Fixes https://github.com/vector-im/element-web/issues/15343
This commit is contained in:
parent
524b2dbd22
commit
a45b7e50cd
1 changed files with 16 additions and 10 deletions
|
@ -110,11 +110,9 @@ export default class CallHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnyActiveCall() {
|
getAnyActiveCall() {
|
||||||
const roomsWithCalls = Object.keys(this.calls);
|
for (const call of this.calls.values()) {
|
||||||
for (let i = 0; i < roomsWithCalls.length; i++) {
|
if (call.state !== "ended") {
|
||||||
if (this.calls.get(roomsWithCalls[i]) &&
|
return call;
|
||||||
this.calls.get(roomsWithCalls[i]).call_state !== "ended") {
|
|
||||||
return this.calls.get(roomsWithCalls[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -180,7 +178,7 @@ export default class CallHandler {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
call.on("hangup", () => {
|
call.on("hangup", () => {
|
||||||
this.setCallState(undefined, call.roomId, "ended");
|
this.removeCallForRoom(call.roomId);
|
||||||
});
|
});
|
||||||
// map web rtc states to dummy UI state
|
// map web rtc states to dummy UI state
|
||||||
// ringing|ringback|connected|ended|busy|stop_ringback|stop_ringing
|
// ringing|ringback|connected|ended|busy|stop_ringback|stop_ringing
|
||||||
|
@ -192,7 +190,7 @@ export default class CallHandler {
|
||||||
this.setCallState(call, call.roomId, "ringback");
|
this.setCallState(call, call.roomId, "ringback");
|
||||||
this.play("ringbackAudio");
|
this.play("ringbackAudio");
|
||||||
} else if (newState === "ended" && oldState === "connected") {
|
} else if (newState === "ended" && oldState === "connected") {
|
||||||
this.setCallState(undefined, call.roomId, "ended");
|
this.removeCallForRoom(call.roomId);
|
||||||
this.pause("ringbackAudio");
|
this.pause("ringbackAudio");
|
||||||
this.play("callendAudio");
|
this.play("callendAudio");
|
||||||
} else if (newState === "ended" && oldState === "invite_sent" &&
|
} else if (newState === "ended" && oldState === "invite_sent" &&
|
||||||
|
@ -223,7 +221,11 @@ export default class CallHandler {
|
||||||
console.log(
|
console.log(
|
||||||
`Call state in ${roomId} changed to ${status} (${call ? call.call_state : "-"})`,
|
`Call state in ${roomId} changed to ${status} (${call ? call.call_state : "-"})`,
|
||||||
);
|
);
|
||||||
this.calls.set(roomId, call);
|
if (call) {
|
||||||
|
this.calls.set(roomId, call);
|
||||||
|
} else {
|
||||||
|
this.calls.delete(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
if (status === "ringing") {
|
if (status === "ringing") {
|
||||||
this.play("ringAudio");
|
this.play("ringAudio");
|
||||||
|
@ -241,6 +243,10 @@ export default class CallHandler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private removeCallForRoom(roomId: string) {
|
||||||
|
this.setCallState(null, roomId, null);
|
||||||
|
}
|
||||||
|
|
||||||
private showICEFallbackPrompt() {
|
private showICEFallbackPrompt() {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
const code = sub => <code>{sub}</code>;
|
const code = sub => <code>{sub}</code>;
|
||||||
|
@ -283,7 +289,7 @@ export default class CallHandler {
|
||||||
} else if (payload.type === 'screensharing') {
|
} else if (payload.type === 'screensharing') {
|
||||||
const screenCapErrorString = PlatformPeg.get().screenCaptureErrorString();
|
const screenCapErrorString = PlatformPeg.get().screenCaptureErrorString();
|
||||||
if (screenCapErrorString) {
|
if (screenCapErrorString) {
|
||||||
this.setCallState(undefined, newCall.roomId, "ended");
|
this.removeCallForRoom(newCall.roomId);
|
||||||
console.log("Can't capture screen: " + screenCapErrorString);
|
console.log("Can't capture screen: " + screenCapErrorString);
|
||||||
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'),
|
||||||
|
@ -376,7 +382,7 @@ export default class CallHandler {
|
||||||
return; // no call to hangup
|
return; // no call to hangup
|
||||||
}
|
}
|
||||||
this.calls.get(payload.room_id).hangup();
|
this.calls.get(payload.room_id).hangup();
|
||||||
this.setCallState(null, payload.room_id, "ended");
|
this.removeCallForRoom(payload.room_id);
|
||||||
break;
|
break;
|
||||||
case 'answer':
|
case 'answer':
|
||||||
if (!this.calls.get(payload.room_id)) {
|
if (!this.calls.get(payload.room_id)) {
|
||||||
|
|
Loading…
Reference in a new issue