To be able to resend, stop all voice actions without deleting.

This commit is contained in:
Onuray Sahin 2021-10-12 17:53:56 +03:00
parent 13aee7d162
commit 39d92d8559
4 changed files with 10 additions and 6 deletions

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

@ -1095,6 +1095,8 @@ 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(deleteRecord = false))
views.voiceMessageRecorderView.initVoiceRecordingViews()
}

View File

@ -343,7 +343,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))
@ -649,8 +649,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()
if (deleteRecord) {
deleteRecording()
}
playbackTracker.clear()
}
}