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)
- SIP URI clickable pattern missing '~'
- 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
- Headers colors in IMDN details
- Pixel issue in call quality indicator 2 icon

View file

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