From 3870ea42b7b63c532f4df7c200f6124df4922d5d Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:21:46 +1100 Subject: [PATCH] Search in groupsv2 --- .../java/org/thoughtcrime/securesms/home/HomeActivity.kt | 4 ++-- .../securesms/home/search/GlobalSearchAdapter.kt | 6 ++---- .../securesms/home/search/GlobalSearchAdapterUtils.kt | 6 +++--- 3 files changed, 7 insertions(+), 9 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 574148296d..34260d460f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -134,7 +134,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ) } - is GlobalSearchAdapter.Model.LegacyGroupConversation -> model.groupRecord.encodedId + is GlobalSearchAdapter.Model.GroupConversation -> model.groupRecord.encodedId .let { Recipient.from(this, Address.fromSerialized(it), false) } .let(threadDb::getThreadIdIfExistsFor) .takeIf { it >= 0 } @@ -324,7 +324,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), private val GlobalSearchResult.contactAndGroupList: List get() = contacts.map { GlobalSearchAdapter.Model.Contact(it, it.nickname ?: it.name, it.accountID == publicKey) } + - threads.map(GlobalSearchAdapter.Model::LegacyGroupConversation) + threads.map(GlobalSearchAdapter.Model::GroupConversation) private val GlobalSearchResult.messageResults: List get() { val unreadThreadMap = messages 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 70af080b76..bc9d597641 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 @@ -11,7 +11,6 @@ import network.loki.messenger.databinding.ViewGlobalSearchHeaderBinding import network.loki.messenger.databinding.ViewGlobalSearchResultBinding import network.loki.messenger.databinding.ViewGlobalSearchSubheaderBinding import org.session.libsession.utilities.GroupRecord -import org.session.libsignal.utilities.AccountId import org.thoughtcrime.securesms.search.model.MessageResult import org.thoughtcrime.securesms.ui.GetString import java.security.InvalidParameterException @@ -116,7 +115,7 @@ class GlobalSearchAdapter(private val modelCallback: (Model)->Unit): RecyclerVie fun bind(query: String, model: Model) { binding.searchResultProfilePicture.recycle() when (model) { - is Model.LegacyGroupConversation -> bindModel(query, model) + is Model.GroupConversation -> bindModel(query, model) is Model.Contact -> bindModel(query, model) is Model.Message -> bindModel(query, model) is Model.SavedMessages -> bindModel(model) @@ -137,8 +136,7 @@ class GlobalSearchAdapter(private val modelCallback: (Model)->Unit): RecyclerVie } data class SavedMessages(val currentUserPublicKey: String): Model() data class Contact(val contact: ContactModel, val name: String?, val isSelf: Boolean) : Model() - data class LegacyGroupConversation(val groupRecord: GroupRecord) : Model() - data class ClosedGroupConversation(val sessionId: AccountId) + data class GroupConversation(val groupRecord: GroupRecord) : Model() data class Message(val messageResult: MessageResult, val unread: Int, val isSelf: Boolean) : Model() } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt b/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt index 9930dbff92..58afdae7b6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/search/GlobalSearchAdapterUtils.kt @@ -14,7 +14,7 @@ import org.session.libsession.utilities.recipients.Recipient import org.session.libsession.utilities.truncateIdForDisplay import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.ContentView import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.Contact as ContactModel -import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.LegacyGroupConversation +import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.GroupConversation import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.Header import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.Message import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.SavedMessages @@ -66,7 +66,7 @@ fun ContentView.bindQuery(query: String, model: GlobalSearchAdapter.Model) { binding.searchResultSubtitle.isVisible = true binding.searchResultTitle.text = model.messageResult.conversationRecipient.getSearchName() } - is LegacyGroupConversation -> { + is GroupConversation -> { binding.searchResultTitle.text = getHighlight( query, model.groupRecord.title @@ -87,7 +87,7 @@ private fun getHighlight(query: String?, toSearch: String): Spannable? { return SearchUtil.getHighlightedSpan(Locale.getDefault(), BoldStyleFactory, toSearch, query) } -fun ContentView.bindModel(query: String?, model: LegacyGroupConversation) { +fun ContentView.bindModel(query: String?, model: GroupConversation) { binding.searchResultProfilePicture.isVisible = true binding.searchResultSubtitle.isVisible = model.groupRecord.isLegacyGroup binding.searchResultTimestamp.isVisible = false