Add name to Model.Contact to fix diffing in search as Contact.equals only checks accountId

This commit is contained in:
bemusementpark 2024-07-12 12:09:48 +09:30
parent afe1295289
commit 0992d12d71
2 changed files with 3 additions and 3 deletions

View File

@ -273,10 +273,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
.flatMap { (key, contacts) -> .flatMap { (key, contacts) ->
listOf( listOf(
GlobalSearchAdapter.Model.SubHeader(key) 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 { } 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) result.threads.map(GlobalSearchAdapter.Model::GroupConversation)
val contactResults = contactAndGroupList.toMutableList() val contactResults = contactAndGroupList.toMutableList()

View File

@ -134,7 +134,7 @@ class GlobalSearchAdapter(private val modelCallback: (Model)->Unit): RecyclerVie
constructor(title: String): this(GetString(title)) constructor(title: String): this(GetString(title))
} }
data class SavedMessages(val currentUserPublicKey: String): Model() 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 GroupConversation(val groupRecord: GroupRecord): Model()
data class Message(val messageResult: MessageResult, val unread: Int, val isSelf: Boolean): Model() data class Message(val messageResult: MessageResult, val unread: Int, val isSelf: Boolean): Model()
} }