diff --git a/ts/background.ts b/ts/background.ts index c2f25669f..e229d5933 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -1709,7 +1709,7 @@ export async function startApp(): Promise { }); window.Whisper.events.on('powerMonitorLockScreen', () => { - window.reduxActions.calling.hangUpActiveCall(); + window.reduxActions.calling.hangUpActiveCall('powerMonitorLockScreen'); }); const reconnectToWebSocketQueue = new LatestQueue(); diff --git a/ts/components/CallManager.tsx b/ts/components/CallManager.tsx index c9a35a7d1..0fb37012a 100644 --- a/ts/components/CallManager.tsx +++ b/ts/components/CallManager.tsx @@ -93,7 +93,7 @@ export type PropsType = { stopRingtone: () => unknown; switchToPresentationView: () => void; switchFromPresentationView: () => void; - hangUpActiveCall: () => void; + hangUpActiveCall: (reason: string) => void; theme: ThemeType; togglePip: () => void; toggleScreenRecordingPermissionsDialog: () => unknown; @@ -187,6 +187,10 @@ const ActiveCallManager: React.FC = ({ [setGroupCallVideoRequest, conversation.id] ); + const onSafetyNumberDialogCancel = useCallback(() => { + hangUpActiveCall('safety number dialog cancel'); + }, [hangUpActiveCall]); + let isCallFull: boolean; let showCallLobby: boolean; let groupMembers: @@ -351,7 +355,7 @@ const ActiveCallManager: React.FC = ({ contacts={activeCall.conversationsWithSafetyNumberChanges} getPreferredBadge={getPreferredBadge} i18n={i18n} - onCancel={hangUpActiveCall} + onCancel={onSafetyNumberDialogCancel} onConfirm={() => { keyChangeOk({ conversationId: activeCall.conversation.id }); }} diff --git a/ts/components/CallScreen.tsx b/ts/components/CallScreen.tsx index b9beef6b0..b924be5fd 100644 --- a/ts/components/CallScreen.tsx +++ b/ts/components/CallScreen.tsx @@ -51,7 +51,7 @@ export type PropsType = { getGroupCallVideoFrameSource: (demuxId: number) => VideoFrameSource; getPresentingSources: () => void; groupMembers?: Array>; - hangUpActiveCall: () => void; + hangUpActiveCall: (reason: string) => void; i18n: LocalizerType; joinedAt?: number; me: ConversationType; @@ -181,6 +181,10 @@ export const CallScreen: React.FC = ({ } }, [getPresentingSources, presentingSource, setPresenting]); + const hangUp = useCallback(() => { + hangUpActiveCall('button click'); + }, [hangUpActiveCall]); + const [controlsHover, setControlsHover] = useState(false); const onControlsMouseEnter = useCallback(() => { @@ -521,7 +525,7 @@ export const CallScreen: React.FC = ({ i18n={i18n} onMouseEnter={onControlsMouseEnter} onMouseLeave={onControlsMouseLeave} - onClick={hangUpActiveCall} + onClick={hangUp} />
diff --git a/ts/components/CallingPip.tsx b/ts/components/CallingPip.tsx index 2588e2205..2a844daec 100644 --- a/ts/components/CallingPip.tsx +++ b/ts/components/CallingPip.tsx @@ -51,7 +51,7 @@ type SnapCandidate = { export type PropsType = { activeCall: ActiveCallType; getGroupCallVideoFrameSource: (demuxId: number) => VideoFrameSource; - hangUpActiveCall: () => void; + hangUpActiveCall: (reason: string) => void; hasLocalVideo: boolean; i18n: LocalizerType; setGroupCallVideoRequest: (_: Array) => void; @@ -100,6 +100,10 @@ export const CallingPip = ({ setLocalPreview({ element: localVideoRef }); }, [setLocalPreview]); + const hangUp = React.useCallback(() => { + hangUpActiveCall('pip button click'); + }, [hangUpActiveCall]); + const handleMouseMove = React.useCallback( (ev: MouseEvent) => { if (positionState.mode === PositionMode.BeingDragged) { @@ -294,7 +298,7 @@ export const CallingPip = ({