From e8b3399ee081a38b1bfb27e27adf994ff6922d0b Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Wed, 16 Oct 2024 14:40:11 +1100 Subject: [PATCH] SES-2810 - Catering for missing config contacts vs local contacts Making sure we deleted conversations when a contact is missing from the config while existing locally --- .../org/thoughtcrime/securesms/database/Storage.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index a1903cc891..7f4a59e3fc 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -1265,6 +1265,16 @@ open class Storage( } setRecipientHash(recipient, contact.hashCode().toString()) } + + // if we have contacts locally but that are missing from the config, remove their corresponding thread + val removedContacts = getAllContacts().filter { localContact -> + moreContacts.firstOrNull { + it.id == localContact.accountID + } == null + } + removedContacts.forEach { + getThreadId(fromSerialized(it.accountID))?.let(::deleteConversation) + } } override fun addContacts(contacts: List) {