From 1a1a0e7324508859c4ad456b5f5606215ddccddc Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 21 Oct 2020 18:55:57 +0100 Subject: [PATCH] Abort if call has ended and remove stray self(!) --- src/webrtc/call.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/webrtc/call.ts b/src/webrtc/call.ts index 3ea746b92..181eb923b 100644 --- a/src/webrtc/call.ts +++ b/src/webrtc/call.ts @@ -942,6 +942,10 @@ export class MatrixCall extends EventEmitter { setTimeout(resolve, 200); }); + // @ts-ignore: Typescript thinks this is impossible because of the + // check above: it has not heard of async functions + if (this.state === CallState.Ended) return; + const content = { // OpenWebRTC appears to add extra stuff (like the DTLS fingerprint) // to the description when setting it on the peerconnection. @@ -1244,7 +1248,7 @@ export class MatrixCall extends EventEmitter { this.peerConn.close(); } if (shouldEmit) { - this.emit(CallEvent.Hangup, self); + this.emit(CallEvent.Hangup, this); } }