Skip to content

Commit

Permalink
Fix bug where calls could break if rejected from somewhere else (#2189)
Browse files Browse the repository at this point in the history
* 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.

* Use ts-expect-error
  • Loading branch information
dbkr authored Feb 21, 2022
1 parent 080426d commit 7b21890
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/webrtc/callEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ export class CallEventHandler {
} else {
call.onRejectReceived(content as MCallHangupReject);
}
this.calls.delete(content.call_id);

// @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);
}
}
return;
Expand Down

0 comments on commit 7b21890

Please sign in to comment.