diff --git a/Riot/Modules/Room/VoiceMessages/VoiceMessageController.swift b/Riot/Modules/Room/VoiceMessages/VoiceMessageController.swift index 5d1d48254..01a57e742 100644 --- a/Riot/Modules/Room/VoiceMessages/VoiceMessageController.swift +++ b/Riot/Modules/Room/VoiceMessages/VoiceMessageController.swift @@ -130,12 +130,7 @@ public class VoiceMessageController: NSObject, VoiceMessageToolbarViewDelegate, } func voiceMessageToolbarViewDidRequestRecordingCancel(_ toolbarView: VoiceMessageToolbarView) { - isInLockedMode = false - audioPlayer?.stop() - audioRecorder?.stopRecording() - deleteRecordingAtURL(temporaryFileURL) - UINotificationFeedbackGenerator().notificationOccurred(.error) - updateUI() + cancelRecording() } func voiceMessageToolbarViewDidRequestLockedModeRecording(_ toolbarView: VoiceMessageToolbarView) { @@ -259,6 +254,8 @@ public class VoiceMessageController: NSObject, VoiceMessageToolbarViewDelegate, guard isInLockedMode else { if recordDuration ?? 0 >= Constants.minimumRecordingDuration { sendRecordingAtURL(temporaryFileURL) + } else { + cancelRecording() } return } @@ -268,6 +265,19 @@ public class VoiceMessageController: NSObject, VoiceMessageToolbarViewDelegate, updateUI() } + private func cancelRecording() { + isInLockedMode = false + + audioPlayer?.stop() + audioRecorder?.stopRecording() + + deleteRecordingAtURL(temporaryFileURL) + + UINotificationFeedbackGenerator().notificationOccurred(.error) + + updateUI() + } + private func loadDraftRecording() { guard let temporaryFileURL = temporaryFileURL, let roomId = roomId else { diff --git a/changelog.d/4970.bugfix b/changelog.d/4970.bugfix new file mode 100644 index 000000000..365cf4aee --- /dev/null +++ b/changelog.d/4970.bugfix @@ -0,0 +1 @@ +Fixed unintentional voice message drafts on automatically cancelled recordings (under 1 second) \ No newline at end of file