From b66efba169377ff3cdc1cb1c366c5303f43049b2 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 21 Mar 2025 08:23:18 +1000 Subject: [PATCH] callStateChange: Properly handle ReceivedOfferWhileActive event --- ts/state/ducks/calling.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ts/state/ducks/calling.ts b/ts/state/ducks/calling.ts index a65b817606..3fa139dc83 100644 --- a/ts/state/ducks/calling.ts +++ b/ts/state/ducks/calling.ts @@ -1195,7 +1195,18 @@ function callStateChange( CallStateChangeFulfilledActionType > { return async dispatch => { - const { callState, acceptedTime, callEndedReason } = payload; + const { conversationId, callState, acceptedTime, callEndedReason } = + payload; + + // This is a special case were we won't update our local call, because we have an + // ongoing active call. The ended call would stomp on the active call. + if (callEndedReason === CallEndedReason.ReceivedOfferWhileActive) { + const conversation = window.ConversationController.get(conversationId); + log.info( + `callStateChange: Got offer while active for conversation ${conversation?.idForLogging()}` + ); + return; + } const wasAccepted = acceptedTime != null; const isEnded = callState === CallState.Ended && callEndedReason != null;