From 1dc1a4d41b94155a30c2a550d1a3cdbec6a2bf44 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Thu, 27 Jul 2023 20:29:10 -0400 Subject: [PATCH] Graceful calling lobby handling --- ts/services/calling.ts | 4 ---- ts/state/ducks/calling.ts | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 8a69b075c0..1ebdc1e087 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -1783,8 +1783,6 @@ export class CallingClass { await processGroupCallRingCancellation(ringId); } - this.stopCallingLobby(); - if (shouldRing) { log.info('handleGroupCallRingUpdate: ringing'); this.reduxInterface?.receiveIncomingGroupCall({ @@ -1888,8 +1886,6 @@ export class CallingClass { this.attachToCall(conversation, call); - this.stopCallingLobby(); - this.reduxInterface.receiveIncomingDirectCall({ conversationId: conversation.id, isVideoCall: call.isVideoCall, diff --git a/ts/state/ducks/calling.ts b/ts/state/ducks/calling.ts index 97d0e3b9a4..e64a3cac11 100644 --- a/ts/state/ducks/calling.ts +++ b/ts/state/ducks/calling.ts @@ -1025,10 +1025,21 @@ function keyChangeOk( function receiveIncomingDirectCall( payload: IncomingDirectCallType -): IncomingDirectCallActionType { - return { - type: INCOMING_DIRECT_CALL, - payload, +): ThunkAction { + return (dispatch, getState) => { + const callState = getState().calling; + + if ( + callState.activeCallState && + callState.activeCallState.conversationId === payload.conversationId + ) { + calling.stopCallingLobby(); + } + + dispatch({ + type: INCOMING_DIRECT_CALL, + payload, + }); }; }