Fixed missing chat room if you created one and sent a message in it

This commit is contained in:
Sylvain Berfini 2025-02-07 17:09:18 +01:00
parent 9381b459a0
commit 709f7dd3c5

View file

@ -66,7 +66,17 @@ class ConversationsListViewModel
@WorkerThread
override fun onMessageSent(core: Core, chatRoom: ChatRoom, message: ChatMessage) {
reorderChatRooms()
val id = LinphoneUtils.getChatRoomId(chatRoom)
val found = conversations.value.orEmpty().find {
it.id == id
}
if (found == null) {
Log.i("$TAG Message sent for a conversation not yet in the list (probably was empty), adding it")
addChatRoom(chatRoom)
} else {
Log.i("$TAG Message sent for an existing conversation, re-order them")
reorderChatRooms()
}
}
@WorkerThread