Merge pull request #4215 from vector-im/feature/ons/fix_voice_message_resend

Voice message - Do not delete file to be able to resend
This commit is contained in:
Benoit Marty 2021-10-12 18:30:03 +02:00 committed by GitHub
commit 13ec4db8a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 7 deletions

1
changelog.d/4006.bugfix Normal file
View file

@ -0,0 +1 @@
Voice Message not sendable if recorded while flight mode was on

View file

@ -291,6 +291,11 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
filesToDelete.forEach {
tryOrNull { it.delete() }
}
// Delete the temporary voice message file
if (params.attachment.type == ContentAttachmentData.Type.AUDIO && params.attachment.mimeType == MimeTypes.Ogg) {
context.contentResolver.delete(params.attachment.queryUri, null, null)
}
}
}

View file

@ -115,5 +115,5 @@ sealed class RoomDetailAction : VectorViewModelAction {
object PauseRecordingVoiceMessage : RoomDetailAction()
data class PlayOrPauseVoicePlayback(val eventId: String, val messageAudioContent: MessageAudioContent) : RoomDetailAction()
object PlayOrPauseRecordingPlayback : RoomDetailAction()
object EndAllVoiceActions : RoomDetailAction()
data class EndAllVoiceActions(val deleteRecord: Boolean = true) : RoomDetailAction()
}

View file

@ -1093,7 +1093,7 @@ class RoomDetailFragment @Inject constructor(
textComposerViewModel.handle(TextComposerAction.SaveDraft(views.composerLayout.text.toString()))
// We should improve the UX to support going into playback mode when paused and delete the media when the view is destroyed.
roomDetailViewModel.handle(RoomDetailAction.EndAllVoiceActions)
roomDetailViewModel.handle(RoomDetailAction.EndAllVoiceActions(deleteRecord = false))
views.voiceMessageRecorderView.initVoiceRecordingViews()
}

View file

@ -345,7 +345,7 @@ class RoomDetailViewModel @AssistedInject constructor(
is RoomDetailAction.PlayOrPauseVoicePlayback -> handlePlayOrPauseVoicePlayback(action)
RoomDetailAction.PauseRecordingVoiceMessage -> handlePauseRecordingVoiceMessage()
RoomDetailAction.PlayOrPauseRecordingPlayback -> handlePlayOrPauseRecordingPlayback()
RoomDetailAction.EndAllVoiceActions -> handleEndAllVoiceActions()
is RoomDetailAction.EndAllVoiceActions -> handleEndAllVoiceActions(action.deleteRecord)
is RoomDetailAction.RoomUpgradeSuccess -> {
setState {
copy(joinUpgradedRoomAsync = Success(action.replacementRoomId))
@ -651,8 +651,8 @@ class RoomDetailViewModel @AssistedInject constructor(
voiceMessageHelper.startOrPauseRecordingPlayback()
}
private fun handleEndAllVoiceActions() {
voiceMessageHelper.stopAllVoiceActions()
private fun handleEndAllVoiceActions(deleteRecord: Boolean) {
voiceMessageHelper.stopAllVoiceActions(deleteRecord)
}
private fun handlePauseRecordingVoiceMessage() {

View file

@ -217,10 +217,12 @@ class VoiceMessageHelper @Inject constructor(
playbackTicker = null
}
fun stopAllVoiceActions() {
fun stopAllVoiceActions(deleteRecord: Boolean = true) {
stopRecording()
stopPlayback()
deleteRecording()
if (deleteRecord) {
deleteRecording()
}
playbackTracker.clear()
}
}