From 30aab71db1374f34ce70eb80d9f57744c26d9fc4 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Thu, 23 Sep 2021 09:16:23 -0300 Subject: [PATCH] [FIX] Preserve voice message if recording is interrupted (#3397) * https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/3388/commits/7c259096713a73e4e39467b45298222ca16a9d5e * Minor changes Co-authored-by: Marco Jakobs --- app/containers/MessageBox/RecordAudio.tsx | 56 +++++++++++++++++++---- app/containers/MessageBox/styles.ts | 3 +- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/app/containers/MessageBox/RecordAudio.tsx b/app/containers/MessageBox/RecordAudio.tsx index cec55761f..fa6c509ef 100644 --- a/app/containers/MessageBox/RecordAudio.tsx +++ b/app/containers/MessageBox/RecordAudio.tsx @@ -63,20 +63,24 @@ export default class RecordAudio extends React.PureComponent { try { const permission = await Audio.getPermissionsAsync(); @@ -108,17 +116,20 @@ export default class RecordAudio extends React.PureComponent { logEvent(events.ROOM_AUDIO_RECORD); if (!this.isRecorderBusy) { this.isRecorderBusy = true; + this.LastDuration = 0; try { const canRecord = await this.isRecordingPermissionGranted(); if (canRecord) { await Audio.setAudioModeAsync(RECORDING_MODE); + this.setState({ isRecorderActive: true }); this.recording = new Audio.Recording(); await this.recording.prepareToRecordAsync(RECORDING_SETTINGS); this.recording.setOnRecordingStatusUpdate(this.onRecordingStatusUpdate); @@ -159,7 +170,7 @@ export default class RecordAudio extends React.PureComponent + + + + + {this.GetLastDuration} + + + + + + ); + } + return ( @@ -207,9 +244,10 @@ export default class RecordAudio extends React.PureComponent - + - {this.duration} + {this.duration} + - + ); diff --git a/app/containers/MessageBox/styles.ts b/app/containers/MessageBox/styles.ts index 8d934799f..6f4599090 100644 --- a/app/containers/MessageBox/styles.ts +++ b/app/containers/MessageBox/styles.ts @@ -139,7 +139,8 @@ export default StyleSheet.create({ flex: 1, justifyContent: 'space-between' }, - recordingCancelText: { + recordingDurationText: { + width: 60, fontSize: 16, ...sharedStyles.textRegular },