Fixed issue when clicking on send message while voice recording is in progress

This commit is contained in:
Sylvain Berfini 2023-02-10 14:29:36 +01:00
parent 312f8c51c2
commit 5e5937382d
2 changed files with 11 additions and 1 deletions

View file

@ -22,6 +22,7 @@ Group changes to describe their impact on the project, as follows:
- Wrong country displayed in assistant after picking it in the list if another country has the same international prefix (such as +1) - Wrong country displayed in assistant after picking it in the list if another country has the same international prefix (such as +1)
- SIP URI clickable pattern missing '~' - SIP URI clickable pattern missing '~'
- Crash that happens sometimes when CallActivity is destroyed - Crash that happens sometimes when CallActivity is destroyed
- Pressing send message button while recording a voice message not sending it
- Missing ephemeral icon next to send message icon - Missing ephemeral icon next to send message icon
- Headers colors in IMDN details - Headers colors in IMDN details
- Pixel issue in call quality indicator 2 icon - Pixel issue in call quality indicator 2 icon

View file

@ -213,6 +213,10 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
stopVoiceRecordPlayer() stopVoiceRecordPlayer()
} }
if (isVoiceRecording.value == true) {
stopVoiceRecorder()
}
val pendingMessageToReplyTo = pendingChatMessageToReplyTo.value val pendingMessageToReplyTo = pendingChatMessageToReplyTo.value
val message: ChatMessage = if (isPendingAnswer.value == true && pendingMessageToReplyTo != null) val message: ChatMessage = if (isPendingAnswer.value == true && pendingMessageToReplyTo != null)
chatRoom.createReplyMessage(pendingMessageToReplyTo.chatMessage) chatRoom.createReplyMessage(pendingMessageToReplyTo.chatMessage)
@ -403,7 +407,7 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
} }
} }
fun stopVoiceRecording() { private fun stopVoiceRecorder() {
if (recorder.state == RecorderState.Running) { if (recorder.state == RecorderState.Running) {
Log.i("[Chat Message Sending] Pausing / closing voice recorder") Log.i("[Chat Message Sending] Pausing / closing voice recorder")
recorder.pause() recorder.pause()
@ -418,6 +422,11 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
} }
isVoiceRecording.value = false isVoiceRecording.value = false
}
fun stopVoiceRecording() {
stopVoiceRecorder()
if (corePreferences.sendVoiceRecordingRightAway) { if (corePreferences.sendVoiceRecordingRightAway) {
Log.i("[Chat Message Sending] Sending voice recording right away") Log.i("[Chat Message Sending] Sending voice recording right away")
sendMessage() sendMessage()