diff --git a/ts/components/CallManager.dom.stories.tsx b/ts/components/CallManager.dom.stories.tsx index e022370729..da479e472b 100644 --- a/ts/components/CallManager.dom.stories.tsx +++ b/ts/components/CallManager.dom.stories.tsx @@ -145,7 +145,6 @@ const createProps = (storyProps: Partial = {}): PropsType => ({ setGroupCallVideoRequest: action('set-group-call-video-request'), setIsCallActive: action('set-is-call-active'), setLocalAudio: action('set-local-audio'), - setLocalAudioRemoteMuted: action('set-local-audio-remote-muted'), setLocalPreviewContainer: action('set-local-preview-container'), setLocalVideo: action('set-local-video'), setRendererCanvas: action('set-renderer-canvas'), diff --git a/ts/components/CallManager.dom.tsx b/ts/components/CallManager.dom.tsx index 2e4635703a..c5b72dc6cb 100644 --- a/ts/components/CallManager.dom.tsx +++ b/ts/components/CallManager.dom.tsx @@ -35,7 +35,6 @@ import type { SendGroupCallReactionType, SetGroupCallVideoRequestType, SetLocalAudioType, - SetMutedByType, SetLocalVideoType, SetRendererCanvasType, StartCallType, @@ -139,7 +138,6 @@ export type PropsType = { setIsCallActive: (_: boolean) => void; setLocalAudio: SetLocalAudioType; setLocalVideo: SetLocalVideoType; - setLocalAudioRemoteMuted: SetMutedByType; setLocalPreviewContainer: (options: SetLocalPreviewContainerType) => void; setOutgoingRing: (_: boolean) => void; setRendererCanvas: (_: SetRendererCanvasType) => void; @@ -204,7 +202,6 @@ function ActiveCallManager({ sendGroupCallReaction, setGroupCallVideoRequest, setLocalAudio, - setLocalAudioRemoteMuted, setLocalPreviewContainer, setLocalVideo, setRendererCanvas, @@ -489,7 +486,6 @@ function ActiveCallManager({ setLocalPreviewContainer={setLocalPreviewContainer} setRendererCanvas={setRendererCanvas} setLocalAudio={setLocalAudio} - setLocalAudioRemoteMuted={setLocalAudioRemoteMuted} setLocalVideo={setLocalVideo} stickyControls={showParticipantsList} switchToPresentationView={switchToPresentationView} @@ -581,7 +577,6 @@ export function CallManager({ setGroupCallVideoRequest, setIsCallActive, setLocalAudio, - setLocalAudioRemoteMuted, setLocalPreviewContainer, setLocalVideo, setOutgoingRing, @@ -696,7 +691,6 @@ export function CallManager({ sendGroupCallReaction={sendGroupCallReaction} setGroupCallVideoRequest={setGroupCallVideoRequest} setLocalAudio={setLocalAudio} - setLocalAudioRemoteMuted={setLocalAudioRemoteMuted} setLocalPreviewContainer={setLocalPreviewContainer} setLocalVideo={setLocalVideo} setOutgoingRing={setOutgoingRing} diff --git a/ts/components/CallScreen.dom.stories.tsx b/ts/components/CallScreen.dom.stories.tsx index 16303746db..d28246800d 100644 --- a/ts/components/CallScreen.dom.stories.tsx +++ b/ts/components/CallScreen.dom.stories.tsx @@ -252,7 +252,6 @@ const createProps = ( sendGroupCallReaction: action('send-group-call-reaction'), setGroupCallVideoRequest: action('set-group-call-video-request'), setLocalAudio: action('set-local-audio'), - setLocalAudioRemoteMuted: action('set-local-audio-remote-muted'), setLocalPreviewContainer: action('set-local-preview-container'), setLocalVideo: action('set-local-video'), setRendererCanvas: action('set-renderer-canvas'), diff --git a/ts/components/CallScreen.dom.tsx b/ts/components/CallScreen.dom.tsx index 1bc19313e0..fefae068f1 100644 --- a/ts/components/CallScreen.dom.tsx +++ b/ts/components/CallScreen.dom.tsx @@ -14,7 +14,6 @@ import type { SetLocalAudioType, SetLocalVideoType, SetRendererCanvasType, - SetMutedByType, } from '../state/ducks/calling.preload.ts'; import { Avatar, AvatarSize } from './Avatar.dom.tsx'; import { @@ -154,7 +153,6 @@ export type PropsType = { toggleSelfViewExpanded: () => void; toggleSettings: () => void; changeCallView: (mode: CallViewMode) => void; - setLocalAudioRemoteMuted: SetMutedByType; }; const REACTIONS_TOASTS_TRANSITION_FROM = { @@ -239,7 +237,6 @@ export function CallScreen({ toggleScreenRecordingPermissionsDialog, toggleSelfViewExpanded, toggleSettings, - setLocalAudioRemoteMuted, }: PropsType): React.JSX.Element { const { conversation, @@ -1131,7 +1128,6 @@ export function CallScreen({ } conversationsByDemuxId={conversationsByDemuxId} i18n={i18n} - setLocalAudioRemoteMuted={setLocalAudioRemoteMuted} /> {isCallLinkAdmin ? ( ; i18n: LocalizerType; }): void { @@ -352,9 +349,6 @@ function useMutedByToast({ const MUTED_BY_TOAST_KEY = 'MUTED_BY_TOAST_KEY'; useEffect(() => { - if (setLocalAudioRemoteMuted === undefined) { - return; - } if ( mutedBy === undefined || // if it's undefined, likely we just received a remote mute request @@ -369,7 +363,6 @@ function useMutedByToast({ if (title === undefined) { return; } - setLocalAudioRemoteMuted({ mutedBy }); let content; if (otherConversation?.isMe) { content = i18n('icu:CallControls__YouMutedYourselfToast'); @@ -394,7 +387,6 @@ function useMutedByToast({ showToast, hideToast, MUTED_BY_TOAST_KEY, - setLocalAudioRemoteMuted, ]); } @@ -486,7 +478,6 @@ type CallingButtonToastsType = { observedRemoteMute?: ObservedRemoteMuteType; conversationsByDemuxId?: Map; i18n: LocalizerType; - setLocalAudioRemoteMuted?: SetMutedByType; }; export function CallingButtonToastsContainer( @@ -519,7 +510,6 @@ function CallingButtonToasts({ mutedBy, observedRemoteMute, conversationsByDemuxId, - setLocalAudioRemoteMuted, }: CallingButtonToastsType) { useMutedToast({ hasLocalAudio, mutedBy, i18n }); useOutgoingRingToast({ outgoingRing, i18n }); @@ -532,7 +522,6 @@ function CallingButtonToasts({ }); useMutedByToast({ mutedBy, - setLocalAudioRemoteMuted, conversationsByDemuxId, i18n, }); diff --git a/ts/state/ducks/calling.preload.ts b/ts/state/ducks/calling.preload.ts index c28b45a409..7a402eceb2 100644 --- a/ts/state/ducks/calling.preload.ts +++ b/ts/state/ducks/calling.preload.ts @@ -116,6 +116,7 @@ import { addCallHistory, reloadCallHistory } from './callHistory.preload.ts'; import { saveDraftRecordingIfNeeded } from './composer.preload.ts'; import type { StartCallData } from '../../components/ConfirmLeaveCallModal.dom.tsx'; import { + getActiveCallState, getCallLinksByRoomId, getPresentingSource, } from '../selectors/calling.std.ts'; @@ -2025,28 +2026,6 @@ function setLocalAudio( }; } -function setLocalAudioRemoteMuted( - payload: Parameters[0] -): ThunkAction { - return (dispatch, getState) => { - const activeCall = getActiveCall(getState().calling); - if (!activeCall) { - log.warn('Trying to set local audio when no call is active'); - return; - } - - calling.setOutgoingAudioRemoteMuted( - activeCall.conversationId, - payload?.mutedBy - ); - - dispatch({ - type: SET_LOCAL_AUDIO_FULFILLED, - payload: { enabled: false }, - }); - }; -} - function setLocalVideo( payload: Parameters[0] ): ThunkAction { @@ -2089,12 +2068,26 @@ function setMutedBy( payload: Parameters[0] ): ThunkAction { return (dispatch, getState) => { - const activeCall = getActiveCall(getState().calling); + const state = getState(); + const activeCall = getActiveCall(state.calling); if (!activeCall) { log.warn('Trying to set muted by when no call is active'); return; } + const activeCallState = getActiveCallState(state); + if (!activeCallState || !activeCallState.hasLocalAudio) { + log.info( + 'Trying to set muted by when no active call state or already muted' + ); + return; + } + + calling.setOutgoingAudioRemoteMuted( + activeCall.conversationId, + payload.mutedBy + ); + dispatch({ type: SET_MUTED_BY, payload, @@ -3110,7 +3103,6 @@ export const actions = { setIsCallActive, setLocalAudio, setLocalVideo, - setLocalAudioRemoteMuted, setMutedBy, setOutgoingRing, setRendererCanvas, @@ -4364,13 +4356,11 @@ export function reducer( return state; } - const newMutedBy = activeCallState.hasLocalAudio ? mutedBy : undefined; - return { ...state, activeCallState: { ...activeCallState, - mutedBy: newMutedBy, + mutedBy, }, }; } diff --git a/ts/state/smart/CallManager.preload.tsx b/ts/state/smart/CallManager.preload.tsx index d36d1af76d..e70eac023c 100644 --- a/ts/state/smart/CallManager.preload.tsx +++ b/ts/state/smart/CallManager.preload.tsx @@ -437,7 +437,6 @@ export const SmartCallManager = memo(function SmartCallManager() { setGroupCallVideoRequest, setIsCallActive, setLocalAudio, - setLocalAudioRemoteMuted, setLocalVideo, setOutgoingRing, setRendererCanvas, @@ -497,7 +496,6 @@ export const SmartCallManager = memo(function SmartCallManager() { setGroupCallVideoRequest={setGroupCallVideoRequest} setIsCallActive={setIsCallActive} setLocalAudio={setLocalAudio} - setLocalAudioRemoteMuted={setLocalAudioRemoteMuted} setLocalPreviewContainer={setLocalPreviewContainer} setLocalVideo={setLocalVideo} setOutgoingRing={setOutgoingRing}