From 07197003710b5834c181cdcb980aeba2fb21c58d Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 29 Mar 2022 16:14:32 +1100 Subject: [PATCH] do not end call if connection fails, instead wait for new offer --- preload.js | 2 +- ts/session/utils/calling/CallManager.ts | 3 ++- ts/state/ducks/call.tsx | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/preload.js b/preload.js index e3f05df0f..e0c56b2d6 100644 --- a/preload.js +++ b/preload.js @@ -31,7 +31,7 @@ window.getNodeVersion = () => config.node_version; window.sessionFeatureFlags = { useOnionRequests: true, - useCallMessage: false, + useCallMessage: true, }; window.versionInfo = { diff --git a/ts/session/utils/calling/CallManager.ts b/ts/session/utils/calling/CallManager.ts index 1661d9a7a..cb407cd11 100644 --- a/ts/session/utils/calling/CallManager.ts +++ b/ts/session/utils/calling/CallManager.ts @@ -5,6 +5,7 @@ import { openConversationWithMessages } from '../../../state/ducks/conversations import { answerCall, callConnected, + callReconnecting, CallStatusEnum, endCall, incomingCall, @@ -601,7 +602,7 @@ function handleConnectionStateChanged(pubkey: string) { window.log.info('handleConnectionStateChanged :', peerConnection?.connectionState); if (peerConnection?.signalingState === 'closed' || peerConnection?.connectionState === 'failed') { - closeVideoCall(); + window.inboxStore?.dispatch(callReconnecting({ pubkey })); } else if (peerConnection?.connectionState === 'connected') { const firstAudioInput = audioInputsList?.[0].deviceId || undefined; if (firstAudioInput) { diff --git a/ts/state/ducks/call.tsx b/ts/state/ducks/call.tsx index 140469640..8e664ea7d 100644 --- a/ts/state/ducks/call.tsx +++ b/ts/state/ducks/call.tsx @@ -76,6 +76,22 @@ const callSlice = createSlice({ state.callIsInFullScreen = false; return state; }, + callReconnecting(state: CallStateType, action: PayloadAction<{ pubkey: string }>) { + const callerPubkey = action.payload.pubkey; + if (callerPubkey !== state.ongoingWith) { + window.log.info('cannot reconnect a call we did not start or receive first'); + return state; + } + const existingCallState = state.ongoingCallStatus; + + if (existingCallState !== 'ongoing') { + window.log.info('cannot reconnect a call we are not ongoing'); + return state; + } + + state.ongoingCallStatus = 'connecting'; + return state; + }, startingCallWith(state: CallStateType, action: PayloadAction<{ pubkey: string }>) { if (state.ongoingWith) { window.log.warn('cannot start a call with an ongoing call already: ongoingWith'); @@ -112,6 +128,7 @@ export const { endCall, answerCall, callConnected, + callReconnecting, startingCallWith, setFullScreenCall, } = actions;