mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-09 08:38:43 +01:00
Always stop all voice actions and media player if app enters to the background.
This commit is contained in:
parent
5168d715ce
commit
aae75ce52f
@ -872,11 +872,14 @@ class MessageComposerViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
private fun handleEntersBackground(composerText: String) {
|
||||
// Always stop all voice actions. It may be playing in timeline or active recording
|
||||
val playingAudioContent = voiceMessageHelper.stopAllVoiceActions(deleteRecord = false)
|
||||
voiceMessageHelper.clearTracker()
|
||||
|
||||
val isVoiceRecording = com.airbnb.mvrx.withState(this) { it.isVoiceRecording }
|
||||
if (isVoiceRecording) {
|
||||
voiceMessageHelper.clearTracker()
|
||||
viewModelScope.launch {
|
||||
voiceMessageHelper.stopAllVoiceActions(deleteRecord = false)?.toContentAttachmentData()?.let { voiceDraft ->
|
||||
playingAudioContent?.toContentAttachmentData()?.let { voiceDraft ->
|
||||
val content = voiceDraft.toJsonString()
|
||||
room.saveDraft(UserDraft.Voice(content))
|
||||
setState { copy(sendMode = SendMode.Voice(content)) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user