From 0992d12d71ef5dd37639f924e59de21377d6f6a0 Mon Sep 17 00:00:00 2001 From: bemusementpark Date: Fri, 12 Jul 2024 12:09:48 +0930 Subject: [PATCH] Add name to Model.Contact to fix diffing in search as Contact.equals only checks accountId --- .../main/java/org/thoughtcrime/securesms/home/HomeActivity.kt | 4 ++-- .../thoughtcrime/securesms/home/search/GlobalSearchAdapter.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index 84f497b702..c17810a646 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -273,10 +273,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), .flatMap { (key, contacts) -> listOf( GlobalSearchAdapter.Model.SubHeader(key) - ) + contacts.sortedBy { it.name ?: it.value.accountID }.map { it.value }.map { GlobalSearchAdapter.Model.Contact(it, it.accountID == publicKey) } + ) + contacts.sortedBy { it.name ?: it.value.accountID }.map { it.value }.map { GlobalSearchAdapter.Model.Contact(it, it.nickname ?: it.name, it.accountID == publicKey) } } } else { - val contactAndGroupList = result.contacts.map { GlobalSearchAdapter.Model.Contact(it, it.accountID == publicKey) } + + val contactAndGroupList = result.contacts.map { GlobalSearchAdapter.Model.Contact(it, it.nickname ?: it.name, it.accountID == publicKey) } + result.threads.map(GlobalSearchAdapter.Model::GroupConversation) val contactResults = contactAndGroupList.toMutableList() diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapter.kt index c7db4fc8b7..27f858c92b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapter.kt @@ -134,7 +134,7 @@ class GlobalSearchAdapter(private val modelCallback: (Model)->Unit): RecyclerVie constructor(title: String): this(GetString(title)) } data class SavedMessages(val currentUserPublicKey: String): Model() - data class Contact(val contact: ContactModel, val isSelf: Boolean): Model() + data class Contact(val contact: ContactModel, val name: String?, val isSelf: Boolean): Model() data class GroupConversation(val groupRecord: GroupRecord): Model() data class Message(val messageResult: MessageResult, val unread: Int, val isSelf: Boolean): Model() }