mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
Search in groupsv2
This commit is contained in:
parent
e68f69a555
commit
3870ea42b7
@ -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<GlobalSearchAdapter.Model> 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<GlobalSearchAdapter.Model> get() {
|
||||
val unreadThreadMap = messages
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user