Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-58561] Calls: Add stop recording confirmation; update call screen #8007

Merged
merged 6 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions app/products/calls/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,54 @@ export const recordingAlert = (isHost: boolean, transcriptionsEnabled: boolean,
);
};

export const stopRecordingConfirmationAlert = (intl: IntlShape, enableTranscriptions: boolean) => {
const {formatMessage} = intl;

const asyncAlert = async () => new Promise((resolve) => {
let title = formatMessage({
id: 'mobile.calls_host_rec_stop_title',
defaultMessage: 'Stop recording',
});
let body = formatMessage({
id: 'mobile.calls_host_rec_stop_body',
defaultMessage: 'The call recording will be processed and posted in the call thread. Are you sure you want to stop the recording?',
});

if (enableTranscriptions) {
title = formatMessage({
id: 'mobile.calls_host_rec_trans_stop_title',
defaultMessage: 'Stop recording and transcription',
});
body = formatMessage({
id: 'mobile.calls_host_rec_trans_stop_body',
defaultMessage: 'The call recording and transcription files will be processed and posted in the call thread. Are you sure you want to stop the recording and transcription?',
});
}

Alert.alert(
title,
body,
[{
text: formatMessage({
id: 'mobile.calls_cancel',
defaultMessage: 'Cancel',
}),
onPress: () => resolve(false),
style: 'cancel',
}, {
text: formatMessage({
id: 'mobile.calls_host_rec_stop_confirm',
defaultMessage: 'Stop recording',
}),
onPress: () => resolve(true),
style: 'destructive',
}],
);
});

return asyncAlert();
};

export const needsRecordingWillBePostedAlert = () => {
recordingWillBePostedLock = false;
};
Expand Down
6 changes: 5 additions & 1 deletion app/products/calls/components/call_duration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import {toMilliseconds} from '@utils/datetime';
type CallDurationProps = {
style: StyleProp<TextStyle>;
value: number;
truncateWhenLong?: boolean;
updateIntervalInSeconds?: number;
}

const CallDuration = ({value, style, updateIntervalInSeconds}: CallDurationProps) => {
const CallDuration = ({value, style, truncateWhenLong, updateIntervalInSeconds}: CallDurationProps) => {
const getCallDuration = () => {
const now = moment();
const startTime = moment(value);
Expand All @@ -27,6 +28,9 @@ const CallDuration = ({value, style, updateIntervalInSeconds}: CallDurationProps
const minutes = totalMinutes % 60;
const hours = Math.floor(totalMinutes / 60);

if (hours > 0 && truncateWhenLong) {
return `${hours}:${minutes < 10 ? '0' + minutes : minutes}`;
}
if (hours > 0) {
return `${hours}:${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`;
}
Expand Down
24 changes: 6 additions & 18 deletions app/products/calls/components/calls_badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ const styles = StyleSheet.create({
borderRadius: 4,
},
loading: {
paddingLeft: 8,
paddingRight: 8,
marginRight: 8,
padding: 6,
color: 'white',
height: 34,
backgroundColor: 'rgba(255, 255, 255, 0.16)',
},
recording: {
paddingLeft: 8,
paddingRight: 8,
marginRight: 8,
padding: 6,
color: 'white',
height: 34,
backgroundColor: '#D24B4E',
},
text: {
Expand Down Expand Up @@ -69,19 +63,13 @@ const CallsBadge = ({type}: Props) => {
const isRec = type === CallsBadgeType.Rec;
const isParticipant = !(isLoading || isRec);

const text = isLoading || isRec ? (
<FormattedText
id={'mobile.calls_rec'}
defaultMessage={'rec'}
style={[styles.text, styles.recordingText]}
/>
) : (
const text = isParticipant ? (
<FormattedText
id={'mobile.calls_host'}
defaultMessage={'host'}
style={[styles.text, styles.recordingText]}
/>
);
) : null;

const containerStyles = [
styles.container,
Expand All @@ -92,13 +80,13 @@ const CallsBadge = ({type}: Props) => {
return (
<View style={containerStyles}>
{
isLoading && <Loading/>
isLoading && <Loading size={16}/>
}
{
isRec &&
<CompassIcon
name={'record-circle-outline'}
size={12}
size={16}
color={styles.text.color}
/>
}
Expand Down
65 changes: 42 additions & 23 deletions app/products/calls/screens/call_screen/call_screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ import {RTCView} from 'react-native-webrtc';

import {leaveCall, muteMyself, unmuteMyself} from '@calls/actions';
import {startCallRecording, stopCallRecording} from '@calls/actions/calls';
import {recordingAlert, recordingWillBePostedAlert, recordingErrorAlert} from '@calls/alerts';
import {
recordingAlert,
recordingWillBePostedAlert,
recordingErrorAlert,
stopRecordingConfirmationAlert,
} from '@calls/alerts';
import {AudioDeviceButton} from '@calls/components/audio_device_button';
import CallDuration from '@calls/components/call_duration';
import CallNotification from '@calls/components/call_notification';
Expand Down Expand Up @@ -120,9 +125,25 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: CallsTheme) => ({
flexDirection: 'row',
alignItems: 'center',
width: '100%',
height: 56,
height: 52,
gap: 8,
},
headerLeft: {
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
paddingLeft: 24,
width: 117,
gap: 8,
},
time: {
color: theme.buttonColor,
...typography('Heading', 200),
width: 56,
},
timeSpacer: {
marginLeft: 36,
},
headerPortraitSpacer: {
height: 12,
},
Expand All @@ -136,22 +157,11 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: CallsTheme) => ({
headerLandscapeNoControls: {
top: -1000,
},
time: {
color: theme.buttonColor,
...typography('Heading', 200),
width: 56,
marginLeft: 24,
marginRight: 8,
marginVertical: 2,
},
collapseIconContainer: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: 48,
height: 48,
marginLeft: 24,
marginRight: 8,
justifyContent: 'flex-end',
width: 117,
},
collapseIcon: {
color: changeOpacity(theme.buttonColor, 0.56),
Expand Down Expand Up @@ -411,14 +421,20 @@ const CallScreen = ({
}, [currentCall?.channelId, currentCall?.serverUrl]);

const stopRecording = useCallback(async () => {
const stop = await stopRecordingConfirmationAlert(intl, EnableTranscriptions);

if (!stop) {
return;
}

Keyboard.dismiss();
await dismissBottomSheet();
if (!currentCall) {
return;
}

await stopCallRecording(currentCall.serverUrl, currentCall.channelId);
}, [currentCall?.channelId, currentCall?.serverUrl]);
}, [currentCall?.channelId, currentCall?.serverUrl, EnableTranscriptions]);

const toggleCC = useCallback(async () => {
Keyboard.dismiss();
Expand Down Expand Up @@ -686,13 +702,16 @@ const CallScreen = ({
isLandscape && !showControlsInLandscape && style.headerLandscapeNoControls,
]}
>
{waitingForRecording && <CallsBadge type={CallsBadgeType.Waiting}/>}
{recording && <CallsBadge type={CallsBadgeType.Rec}/>}
<CallDuration
style={style.time}
value={currentCall.startTime}
updateIntervalInSeconds={1}
/>
<View style={style.headerLeft}>
{waitingForRecording && <CallsBadge type={CallsBadgeType.Waiting}/>}
{recording && <CallsBadge type={CallsBadgeType.Rec}/>}
<CallDuration
style={[style.time, !(waitingForRecording || recording) && style.timeSpacer]}
value={currentCall.startTime}
updateIntervalInSeconds={1}
truncateWhenLong={true}
/>
</View>
<HeaderCenter
raisedHands={raisedHands}
sessionId={currentCall.mySessionId}
Expand Down
1 change: 1 addition & 0 deletions app/products/calls/screens/call_screen/header_center.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: CallsTheme) => ({
titleBanner: {
...typography('Body', 200, 'SemiBold'),
color: changeOpacity(theme.buttonColor, 0.72),
height: 28,
},
}));

Expand Down
7 changes: 6 additions & 1 deletion assets/base/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
"mobile.calls_call_ended": "Call ended",
"mobile.calls_call_screen": "Call",
"mobile.calls_call_thread": "Call Thread",
"mobile.calls_cancel": "Cancel",
"mobile.calls_captions": "Captions",
"mobile.calls_captions_turned_on": "Live captions turned on",
"mobile.calls_disable": "Disable calls",
Expand All @@ -466,9 +467,14 @@
"mobile.calls_host_rec": "You are recording this meeting. Consider letting everyone know that this meeting is being recorded.",
"mobile.calls_host_rec_error": "Please try to record again. You can also contact your system admin for troubleshooting help.",
"mobile.calls_host_rec_error_title": "Something went wrong with the recording",
"mobile.calls_host_rec_stop_body": "The call recording will be processed and posted in the call thread. Are you sure you want to stop the recording?",
"mobile.calls_host_rec_stop_confirm": "Stop recording",
"mobile.calls_host_rec_stop_title": "Stop recording",
"mobile.calls_host_rec_stopped": "You can find the recording in this call's chat thread once it's finished processing.",
"mobile.calls_host_rec_stopped_title": "Recording has stopped. Processing...",
"mobile.calls_host_rec_title": "You are recording",
"mobile.calls_host_rec_trans_stop_body": "The call recording and transcription files will be processed and posted in the call thread. Are you sure you want to stop the recording and transcription?",
"mobile.calls_host_rec_trans_stop_title": "Stop recording and transcription",
"mobile.calls_host_transcription": "Consider letting everyone know that this meeting is being recorded and transcribed.",
"mobile.calls_host_transcription_title": "Recording and transcription has started",
"mobile.calls_incoming_dm": "<b>{name}</b> is inviting you to a call",
Expand Down Expand Up @@ -510,7 +516,6 @@
"mobile.calls_raise_hand": "Raise hand",
"mobile.calls_raised_hand": "<bold>{name} {num, plural, =0 {} other {+# more }}</bold>raised a hand",
"mobile.calls_react": "React",
"mobile.calls_rec": "rec",
"mobile.calls_record": "Record",
"mobile.calls_recording_start_in_progress": "A recording is already in progress.",
"mobile.calls_recording_start_no_permissions": "You don't have permissions to start a recording. Please ask the call host to start a recording.",
Expand Down