Fixed some chat related issues
This commit is contained in:
parent
a221e1fdbb
commit
a284a55d8e
2 changed files with 9 additions and 4 deletions
|
@ -24,7 +24,10 @@ import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.core.*
|
import org.linphone.core.ChatMessage
|
||||||
|
import org.linphone.core.ChatRoom
|
||||||
|
import org.linphone.core.ChatRoomCapabilities
|
||||||
|
import org.linphone.core.Factory
|
||||||
import org.linphone.utils.FileUtils
|
import org.linphone.utils.FileUtils
|
||||||
|
|
||||||
class ChatMessageSendingViewModelFactory(private val chatRoom: ChatRoom) :
|
class ChatMessageSendingViewModelFactory(private val chatRoom: ChatRoom) :
|
||||||
|
@ -103,7 +106,7 @@ class ChatMessageSendingViewModel(private val chatRoom: ChatRoom) : ViewModel()
|
||||||
|
|
||||||
val toSend = textToSend.value
|
val toSend = textToSend.value
|
||||||
if (toSend != null && toSend.isNotEmpty()) {
|
if (toSend != null && toSend.isNotEmpty()) {
|
||||||
message.addTextContent(toSend)
|
message.addUtf8TextContent(toSend)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (attachment in attachments.value.orEmpty()) {
|
for (attachment in attachments.value.orEmpty()) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ChatMessagesListViewModel(private val chatRoom: ChatRoom) : ViewModel() {
|
||||||
addEvent(eventLog)
|
addEvent(eventLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChatMessageSent(chatRoom: ChatRoom, eventLog: EventLog) {
|
override fun onChatMessageSending(chatRoom: ChatRoom, eventLog: EventLog) {
|
||||||
val position = events.value.orEmpty().size
|
val position = events.value.orEmpty().size
|
||||||
|
|
||||||
if (eventLog.type == EventLog.Type.ConferenceChatMessage) {
|
if (eventLog.type == EventLog.Type.ConferenceChatMessage) {
|
||||||
|
@ -208,7 +208,9 @@ class ChatMessagesListViewModel(private val chatRoom: ChatRoom) : ViewModel() {
|
||||||
private fun addEvent(eventLog: EventLog) {
|
private fun addEvent(eventLog: EventLog) {
|
||||||
val list = arrayListOf<EventLog>()
|
val list = arrayListOf<EventLog>()
|
||||||
list.addAll(events.value.orEmpty())
|
list.addAll(events.value.orEmpty())
|
||||||
list.add(eventLog)
|
if (!list.contains(eventLog)) {
|
||||||
|
list.add(eventLog)
|
||||||
|
}
|
||||||
events.value = list
|
events.value = list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue