From 5c77b58154c65d64716878b56daa67b3b9cafc8b Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 26 Aug 2024 11:05:55 +0200 Subject: [PATCH] Prevent case causing memory chat room to be re-used as a diffent one, leading to duplicated listener --- .../viewmodel/AbstractConversationViewModel.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/main/chat/viewmodel/AbstractConversationViewModel.kt b/app/src/main/java/org/linphone/ui/main/chat/viewmodel/AbstractConversationViewModel.kt index 37d484513..9958ca1ef 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/viewmodel/AbstractConversationViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/viewmodel/AbstractConversationViewModel.kt @@ -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))