Prevent case causing memory chat room to be re-used as a diffent one, leading to duplicated listener

This commit is contained in:
Sylvain Berfini 2024-08-26 11:05:55 +02:00
parent ce1c3dad65
commit 5c77b58154

View file

@ -105,11 +105,19 @@ abstract class AbstractConversationViewModel : GenericViewModel() {
)
)
if (found != null) {
chatRoom = found
if (::chatRoom.isInitialized && chatRoom == found) {
Log.i("$TAG Conversation object already in memory, keeping it")
beforeNotifyingChatRoomFound(sameOne = true)
chatRoomFoundEvent.postValue(Event(true))
afterNotifyingChatRoomFound(sameOne = true)
} else {
chatRoom = found
Log.i("$TAG Found conversation in Core, using it")
beforeNotifyingChatRoomFound(sameOne = false)
chatRoomFoundEvent.postValue(Event(true))
afterNotifyingChatRoomFound(sameOne = false)
beforeNotifyingChatRoomFound(sameOne = false)
chatRoomFoundEvent.postValue(Event(true))
afterNotifyingChatRoomFound(sameOne = false)
}
} else {
Log.e("$TAG Failed to find conversation given local & remote addresses!")
chatRoomFoundEvent.postValue(Event(false))