Search in groupsv2

This commit is contained in:
SessionHero01 2024-10-30 16:21:46 +11:00
parent e68f69a555
commit 3870ea42b7
No known key found for this signature in database
3 changed files with 7 additions and 9 deletions

View File

@ -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 { Recipient.from(this, Address.fromSerialized(it), false) }
.let(threadDb::getThreadIdIfExistsFor) .let(threadDb::getThreadIdIfExistsFor)
.takeIf { it >= 0 } .takeIf { it >= 0 }
@ -324,7 +324,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
private val GlobalSearchResult.contactAndGroupList: List<GlobalSearchAdapter.Model> get() = private val GlobalSearchResult.contactAndGroupList: List<GlobalSearchAdapter.Model> get() =
contacts.map { GlobalSearchAdapter.Model.Contact(it, it.nickname ?: it.name, it.accountID == publicKey) } + 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<GlobalSearchAdapter.Model> get() { private val GlobalSearchResult.messageResults: List<GlobalSearchAdapter.Model> get() {
val unreadThreadMap = messages val unreadThreadMap = messages

View File

@ -11,7 +11,6 @@ import network.loki.messenger.databinding.ViewGlobalSearchHeaderBinding
import network.loki.messenger.databinding.ViewGlobalSearchResultBinding import network.loki.messenger.databinding.ViewGlobalSearchResultBinding
import network.loki.messenger.databinding.ViewGlobalSearchSubheaderBinding import network.loki.messenger.databinding.ViewGlobalSearchSubheaderBinding
import org.session.libsession.utilities.GroupRecord import org.session.libsession.utilities.GroupRecord
import org.session.libsignal.utilities.AccountId
import org.thoughtcrime.securesms.search.model.MessageResult import org.thoughtcrime.securesms.search.model.MessageResult
import org.thoughtcrime.securesms.ui.GetString import org.thoughtcrime.securesms.ui.GetString
import java.security.InvalidParameterException import java.security.InvalidParameterException
@ -116,7 +115,7 @@ class GlobalSearchAdapter(private val modelCallback: (Model)->Unit): RecyclerVie
fun bind(query: String, model: Model) { fun bind(query: String, model: Model) {
binding.searchResultProfilePicture.recycle() binding.searchResultProfilePicture.recycle()
when (model) { when (model) {
is Model.LegacyGroupConversation -> bindModel(query, model) is Model.GroupConversation -> bindModel(query, model)
is Model.Contact -> bindModel(query, model) is Model.Contact -> bindModel(query, model)
is Model.Message -> bindModel(query, model) is Model.Message -> bindModel(query, model)
is Model.SavedMessages -> bindModel(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 SavedMessages(val currentUserPublicKey: String): Model()
data class Contact(val contact: ContactModel, val name: String?, val isSelf: Boolean) : Model() data class Contact(val contact: ContactModel, val name: String?, val isSelf: Boolean) : Model()
data class LegacyGroupConversation(val groupRecord: GroupRecord) : Model() data class GroupConversation(val groupRecord: GroupRecord) : Model()
data class ClosedGroupConversation(val sessionId: AccountId)
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()
} }
} }

View File

@ -14,7 +14,7 @@ import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.truncateIdForDisplay import org.session.libsession.utilities.truncateIdForDisplay
import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.ContentView 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.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.Header
import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.Message import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.Message
import org.thoughtcrime.securesms.home.search.GlobalSearchAdapter.Model.SavedMessages 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.searchResultSubtitle.isVisible = true
binding.searchResultTitle.text = model.messageResult.conversationRecipient.getSearchName() binding.searchResultTitle.text = model.messageResult.conversationRecipient.getSearchName()
} }
is LegacyGroupConversation -> { is GroupConversation -> {
binding.searchResultTitle.text = getHighlight( binding.searchResultTitle.text = getHighlight(
query, query,
model.groupRecord.title model.groupRecord.title
@ -87,7 +87,7 @@ private fun getHighlight(query: String?, toSearch: String): Spannable? {
return SearchUtil.getHighlightedSpan(Locale.getDefault(), BoldStyleFactory, toSearch, query) 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.searchResultProfilePicture.isVisible = true
binding.searchResultSubtitle.isVisible = model.groupRecord.isLegacyGroup binding.searchResultSubtitle.isVisible = model.groupRecord.isLegacyGroup
binding.searchResultTimestamp.isVisible = false binding.searchResultTimestamp.isVisible = false