From 2189a9df7421c494dbeca4235862293ffa41bbcf Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 21 Feb 2022 17:07:52 +0000 Subject: [PATCH 1/2] Fix bug where calls could ignore new events of rejected from somewhere else When callEventHandler passed a reject event to the call object, it assumed that always caused the call to end and deleted it from the list, so it never got any more events. The point of a reject is that it doesn't end the call if it's already been picked up though. This only removes the call if it's actually ended. --- src/webrtc/callEventHandler.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/webrtc/callEventHandler.ts b/src/webrtc/callEventHandler.ts index 7b7ca0f7149..cd13e116a61 100644 --- a/src/webrtc/callEventHandler.ts +++ b/src/webrtc/callEventHandler.ts @@ -257,7 +257,11 @@ export class CallEventHandler { } else { call.onRejectReceived(content as MCallHangupReject); } - this.calls.delete(content.call_id); + + // @ts-ignore typescript thinks the state can't be 'ended' because we're + // inside the if block where it wasn't, but it could have changed because + // on[Hangup|Reject]Received are side-effecty. + if (call.state === CallState.Ended) this.calls.delete(content.call_id); } } return; From d5d53adac55ef714b2c38d49c5a293b9c7a75adf Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 21 Feb 2022 18:47:40 +0000 Subject: [PATCH 2/2] Use ts-expect-error --- src/webrtc/callEventHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webrtc/callEventHandler.ts b/src/webrtc/callEventHandler.ts index cd13e116a61..6599971921e 100644 --- a/src/webrtc/callEventHandler.ts +++ b/src/webrtc/callEventHandler.ts @@ -258,7 +258,7 @@ export class CallEventHandler { call.onRejectReceived(content as MCallHangupReject); } - // @ts-ignore typescript thinks the state can't be 'ended' because we're + // @ts-expect-error typescript thinks the state can't be 'ended' because we're // inside the if block where it wasn't, but it could have changed because // on[Hangup|Reject]Received are side-effecty. if (call.state === CallState.Ended) this.calls.delete(content.call_id);