From 1620ccf3ab06978f34ac38543658b9ce1faf16da Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Tue, 5 Nov 2024 04:05:53 +1000 Subject: [PATCH] Ensure that calls ring at more appropriate times --- ts/services/calling.ts | 13 +++++++++++++ ts/state/ducks/callingHelpers.ts | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 95c39f49a748..0448247c0cfe 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -2950,6 +2950,19 @@ export class CallingClass { localCallEvent, 'CallingClass.handleAutoEndedIncomingCallRequest' ); + + if (!this.reduxInterface) { + log.error( + 'handleAutoEndedIncomingCallRequest: Unable to update redux for call' + ); + } + this.reduxInterface?.callStateChange({ + acceptedTime: null, + callEndedReason, + callState: CallState.Ended, + conversationId: conversation.id, + }); + await updateCallHistoryFromLocalEvent( callEvent, receivedAtCounter ?? null, diff --git a/ts/state/ducks/callingHelpers.ts b/ts/state/ducks/callingHelpers.ts index 159164168bb6..70ad16ab7476 100644 --- a/ts/state/ducks/callingHelpers.ts +++ b/ts/state/ducks/callingHelpers.ts @@ -38,6 +38,13 @@ export const getRingingCall = ( return false; } + if ( + activeCallState?.state === 'Active' && + activeCallState.conversationId !== call.conversationId + ) { + return false; + } + return isRinging(call.callState) && call.callEndedReason == null; }); @@ -50,11 +57,18 @@ export const getRingingCall = ( return false; } + if ( + activeCallState?.state === 'Active' && + activeCallState.conversationId !== call.conversationId + ) { + return false; + } + // Outgoing - ringerAci is not set for outgoing group calls if ( activeCallState?.state === 'Active' && - activeCallState.outgoingRing && activeCallState.conversationId === call.conversationId && + activeCallState.outgoingRing && isConnected(call.connectionState) && isJoined(call.joinState) && !hasRemoteParticipants(call.remoteParticipants)