Skip to content

Commit

Permalink
Fixes #4970 - Fixed unintentional voice message drafts on automatical…
Browse files Browse the repository at this point in the history
…ly cancelled recordings.
  • Loading branch information
stefanceriu committed Oct 8, 2021
1 parent 093b10b commit 031b892
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Riot/Modules/Room/VoiceMessages/VoiceMessageController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -259,6 +254,8 @@ public class VoiceMessageController: NSObject, VoiceMessageToolbarViewDelegate,
guard isInLockedMode else {
if recordDuration ?? 0 >= Constants.minimumRecordingDuration {
sendRecordingAtURL(temporaryFileURL)
} else {
cancelRecording()
}
return
}
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions changelog.d/4970.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed unintentional voice message drafts on automatically cancelled recordings (under 1 second)

0 comments on commit 031b892

Please sign in to comment.