From 5289dc48240c7b566ad5bedf5585dc5c37428c45 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 8 Jul 2024 13:18:47 +0200 Subject: [PATCH] Fixed issue in contacts list if some share the same SIP address(es) --- .../main/java/org/linphone/contacts/ContactsManager.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/linphone/contacts/ContactsManager.kt b/app/src/main/java/org/linphone/contacts/ContactsManager.kt index 821531fb8..00d8e3188 100644 --- a/app/src/main/java/org/linphone/contacts/ContactsManager.kt +++ b/app/src/main/java/org/linphone/contacts/ContactsManager.kt @@ -206,6 +206,14 @@ class ContactsManager @UiThread constructor() { @WorkerThread fun contactRemoved(friend: Friend) { + val refKey = friend.refKey.orEmpty() + if (refKey.isNotEmpty() && knownContactsAvatarsMap.keys.contains(refKey)) { + Log.d("$TAG Found RefKey [$refKey] in knownContactsAvatarsMap, removing it") + val oldModel = knownContactsAvatarsMap[refKey] + oldModel?.destroy() + knownContactsAvatarsMap.remove(refKey) + } + for (sipAddress in friend.addresses) { val sipUri = sipAddress.asStringUriOnly() if (knownContactsAvatarsMap.keys.contains(sipUri)) { @@ -387,7 +395,7 @@ class ContactsManager @UiThread constructor() { "$TAG Looking for avatar model for friend [${friend.name}] using SIP URI [${address.asStringUriOnly()}]" ) - val key = LinphoneUtils.getAddressAsCleanStringUriOnly(address) + val key = friend.refKey ?: LinphoneUtils.getAddressAsCleanStringUriOnly(address) val foundInMap = getAvatarModelFromCache(key) if (foundInMap != null) { Log.d("$TAG Found avatar model in map using SIP URI [$key]")