From 1203f1dc48aa609bc721b4ab9cea53cefd4918b7 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 15 Nov 2021 14:48:03 +1100 Subject: [PATCH] remove none state on callState. instead set it to undefined --- .../session/calling/InConversationCallContainer.tsx | 3 --- ts/models/conversation.ts | 2 +- ts/session/utils/CallManager.ts | 4 ++-- ts/state/ducks/conversations.ts | 8 ++++---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ts/components/session/calling/InConversationCallContainer.tsx b/ts/components/session/calling/InConversationCallContainer.tsx index 4d4702a1b..2a2dc4686 100644 --- a/ts/components/session/calling/InConversationCallContainer.tsx +++ b/ts/components/session/calling/InConversationCallContainer.tsx @@ -24,7 +24,6 @@ import { useModuloWithTripleDots } from '../../../hooks/useModuloWithTripleDots' import { CallWindowControls } from './CallButtons'; import { SessionSpinner } from '../SessionSpinner'; import { DEVICE_DISABLED_DEVICE_ID } from '../../../session/utils/CallManager'; -// import { useCallAudioLevel } from '../../../hooks/useCallAudioLevel'; const VideoContainer = styled.div` height: 100%; @@ -146,8 +145,6 @@ export const InConversationCallContainer = () => { isAudioOutputMuted, } = useVideoCallEventsListener('InConversationCallContainer', true); - // const isSpeaking = useCallAudioLevel(); - if (videoRefRemote?.current && videoRefLocal?.current) { if (videoRefRemote.current.srcObject !== remoteStream) { videoRefRemote.current.srcObject = remoteStream; diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index d7fc0d8cf..6af47dc74 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -176,7 +176,7 @@ export const fillConvoAttributesWithDefaults = ( }); }; -export type CallState = 'offering' | 'incoming' | 'connecting' | 'ongoing' | 'none' | undefined; +export type CallState = 'offering' | 'incoming' | 'connecting' | 'ongoing' | undefined; export class ConversationModel extends Backbone.Model { public updateLastMessage: () => any; diff --git a/ts/session/utils/CallManager.ts b/ts/session/utils/CallManager.ts index 339ce240c..cbb1483b2 100644 --- a/ts/session/utils/CallManager.ts +++ b/ts/session/utils/CallManager.ts @@ -22,7 +22,6 @@ import { PubKey } from '../types'; import { v4 as uuidv4 } from 'uuid'; import { PnServer } from '../../pushnotification'; -// import { SoundMeter } from '../../../ts/components/session/calling/SoundMeter'; import { setIsRinging } from './RingingManager'; export type InputItem = { deviceId: string; label: string }; @@ -531,8 +530,9 @@ function closeVideoCall() { selectedCameraId = DEVICE_DISABLED_DEVICE_ID; selectedAudioInputId = DEVICE_DISABLED_DEVICE_ID; currentCallUUID = undefined; - callVideoListeners(); window.inboxStore?.dispatch(setFullScreenCall(false)); + + callVideoListeners(); } function onDataChannelReceivedMessage(ev: MessageEvent) { diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 973e3e1c7..bc00e05fe 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -765,7 +765,7 @@ const conversationsSlice = createSlice({ incomingCall(state: ConversationsStateType, action: PayloadAction<{ pubkey: string }>) { const callerPubkey = action.payload.pubkey; const existingCallState = state.conversationLookup[callerPubkey].callState; - if (existingCallState !== undefined && existingCallState !== 'none') { + if (existingCallState !== undefined) { return state; } const foundConvo = getConversationController().get(callerPubkey); @@ -784,7 +784,7 @@ const conversationsSlice = createSlice({ endCall(state: ConversationsStateType, action: PayloadAction<{ pubkey: string }>) { const callerPubkey = action.payload.pubkey; const existingCallState = state.conversationLookup[callerPubkey].callState; - if (!existingCallState || existingCallState === 'none') { + if (!existingCallState) { return state; } @@ -796,7 +796,7 @@ const conversationsSlice = createSlice({ // we have to update the model itself. // not the db (as we dont want to store that field in it) // and not the redux store directly as it gets overriden by the commit() of the conversationModel - foundConvo.callState = 'none'; + foundConvo.callState = undefined; void foundConvo.commit(); return state; @@ -840,7 +840,7 @@ const conversationsSlice = createSlice({ startingCallWith(state: ConversationsStateType, action: PayloadAction<{ pubkey: string }>) { const callerPubkey = action.payload.pubkey; const existingCallState = state.conversationLookup[callerPubkey].callState; - if (existingCallState && existingCallState !== 'none') { + if (existingCallState) { return state; } const foundConvo = getConversationController().get(callerPubkey);