do not end call if connection fails, instead wait for new offer

This commit is contained in:
Audric Ackermann 2022-03-29 16:14:32 +11:00
parent 0cb4a13494
commit 0719700371
3 changed files with 20 additions and 2 deletions

View file

@ -31,7 +31,7 @@ window.getNodeVersion = () => config.node_version;
window.sessionFeatureFlags = {
useOnionRequests: true,
useCallMessage: false,
useCallMessage: true,
};
window.versionInfo = {

View file

@ -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) {

View file

@ -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;