1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

Revert "Revert "Fix glare related regressions""

This reverts commit 4c552cc350.
This commit is contained in:
Šimon Brandner
2021-08-17 07:33:40 +02:00
parent 0f45b7e516
commit 0d09f87777
2 changed files with 12 additions and 19 deletions

View File

@@ -80,7 +80,7 @@ export class CallEventHandler {
continue;
}
try {
this.handleCallEvent(e);
await this.handleCallEvent(e);
} catch (e) {
logger.error("Caught exception handling call event", e);
}
@@ -100,7 +100,7 @@ export class CallEventHandler {
if (event.isBeingDecrypted() || event.isDecryptionFailure()) {
// add an event listener for once the event is decrypted.
event.once("Event.decrypted", () => {
event.once("Event.decrypted", async () => {
if (!this.eventIsACall(event)) return;
if (this.callEventBuffer.includes(event)) {
@@ -110,7 +110,7 @@ export class CallEventHandler {
// This one wasn't buffered so just run the event handler for it
// straight away
try {
this.handleCallEvent(event);
await this.handleCallEvent(event);
} catch (e) {
logger.error("Caught exception handling call event", e);
}
@@ -128,7 +128,7 @@ export class CallEventHandler {
return type.startsWith("m.call.") || type.startsWith("org.matrix.call.");
}
private handleCallEvent(event: MatrixEvent) {
private async handleCallEvent(event: MatrixEvent) {
const content = event.getContent();
const type = event.getType() as EventType;
const weSentTheEvent = event.getSender() === this.client.credentials.userId;
@@ -169,7 +169,7 @@ export class CallEventHandler {
}
call.callId = content.call_id;
call.initWithInvite(event);
await call.initWithInvite(event);
this.calls.set(call.callId, call);
// if we stashed candidate events for that call ID, play them back now
@@ -201,9 +201,11 @@ export class CallEventHandler {
// we've got an invite, pick the incoming call because we know
// we haven't sent our invite yet otherwise, pick whichever
// call has the lowest call ID (by string comparison)
if (existingCall.state === CallState.WaitLocalMedia ||
existingCall.state === CallState.CreateOffer ||
existingCall.callId > call.callId) {
if (
existingCall.state === CallState.WaitLocalMedia ||
existingCall.state === CallState.CreateOffer ||
existingCall.callId > call.callId
) {
logger.log(
"Glare detected: answering incoming call " + call.callId +
" and canceling outgoing call " + existingCall.callId,