mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-09 22:04:24 +01:00
Getting users to show up on query
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com> Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
89d51837b7
commit
1ccc3ebb94
@ -99,12 +99,12 @@ class ContactsViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
fun getContactsFromSearchParams() {
|
fun getContactsFromSearchParams(query: String = "") {
|
||||||
_contactsViewState.value = ContactsUiState.Loading
|
_contactsViewState.value = ContactsUiState.Loading
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
val contacts = repository.getContacts(
|
val contacts = repository.getContacts(
|
||||||
searchQuery.value,
|
if (query != "") query else searchQuery.value,
|
||||||
shareTypeList
|
shareTypeList
|
||||||
)
|
)
|
||||||
val contactsList: MutableList<AutocompleteUser>? = contacts.ocs!!.data?.toMutableList()
|
val contactsList: MutableList<AutocompleteUser>? = contacts.ocs!!.data?.toMutableList()
|
||||||
|
@ -211,7 +211,7 @@ class ConversationsListActivity :
|
|||||||
private var adapter: FlexibleAdapter<AbstractFlexibleItem<*>>? = null
|
private var adapter: FlexibleAdapter<AbstractFlexibleItem<*>>? = null
|
||||||
private var conversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
private var conversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
||||||
private var conversationItemsWithHeader: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
private var conversationItemsWithHeader: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
||||||
private val searchableConversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
private var searchableConversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
||||||
private var filterableConversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
private var filterableConversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
||||||
private var nearFutureEventConversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
private var nearFutureEventConversationItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
||||||
private var searchItem: MenuItem? = null
|
private var searchItem: MenuItem? = null
|
||||||
@ -235,9 +235,9 @@ class ConversationsListActivity :
|
|||||||
private var searchViewDisposable: Disposable? = null
|
private var searchViewDisposable: Disposable? = null
|
||||||
private var filterState =
|
private var filterState =
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
FilterConversationFragment.MENTION to false,
|
MENTION to false,
|
||||||
FilterConversationFragment.UNREAD to false,
|
UNREAD to false,
|
||||||
FilterConversationFragment.ARCHIVE to false,
|
ARCHIVE to false,
|
||||||
FilterConversationFragment.DEFAULT to true
|
FilterConversationFragment.DEFAULT to true
|
||||||
)
|
)
|
||||||
val searchBehaviorSubject = BehaviorSubject.createDefault(false)
|
val searchBehaviorSubject = BehaviorSubject.createDefault(false)
|
||||||
@ -461,7 +461,13 @@ class ConversationsListActivity :
|
|||||||
userItems.add(contactItem)
|
userItems.add(contactItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchableConversationItems.addAll(userItems)
|
val list = searchableConversationItems.filter {
|
||||||
|
it !is ContactItem
|
||||||
|
}.toMutableList()
|
||||||
|
|
||||||
|
list.addAll(userItems)
|
||||||
|
|
||||||
|
searchableConversationItems = list
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
@ -557,9 +563,6 @@ class ConversationsListActivity :
|
|||||||
intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1)
|
intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1)
|
||||||
)
|
)
|
||||||
fetchOpenConversations(apiVersion)
|
fetchOpenConversations(apiVersion)
|
||||||
|
|
||||||
// Get users
|
|
||||||
fetchUsers()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun applyFilter() {
|
fun applyFilter() {
|
||||||
@ -637,7 +640,7 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val archiveFilterOn = filterState[FilterConversationFragment.ARCHIVE] ?: false
|
val archiveFilterOn = filterState[ARCHIVE] ?: false
|
||||||
if (archiveFilterOn && newItems.isEmpty()) {
|
if (archiveFilterOn && newItems.isEmpty()) {
|
||||||
binding.noArchivedConversationLayout.visibility = View.VISIBLE
|
binding.noArchivedConversationLayout.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
@ -659,7 +662,7 @@ class ConversationsListActivity :
|
|||||||
for ((k, v) in filterState) {
|
for ((k, v) in filterState) {
|
||||||
if (v) {
|
if (v) {
|
||||||
when (k) {
|
when (k) {
|
||||||
FilterConversationFragment.MENTION -> result = (result && conversation.unreadMention) ||
|
MENTION -> result = (result && conversation.unreadMention) ||
|
||||||
(
|
(
|
||||||
result &&
|
result &&
|
||||||
(
|
(
|
||||||
@ -669,10 +672,10 @@ class ConversationsListActivity :
|
|||||||
(conversation.unreadMessages > 0)
|
(conversation.unreadMessages > 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
FilterConversationFragment.UNREAD -> result = result && (conversation.unreadMessages > 0)
|
UNREAD -> result = result && (conversation.unreadMessages > 0)
|
||||||
|
|
||||||
FilterConversationFragment.DEFAULT -> {
|
FilterConversationFragment.DEFAULT -> {
|
||||||
result = if (filterState[FilterConversationFragment.ARCHIVE] == true) {
|
result = if (filterState[ARCHIVE] == true) {
|
||||||
result && conversation.hasArchived
|
result && conversation.hasArchived
|
||||||
} else {
|
} else {
|
||||||
result && !conversation.hasArchived
|
result && !conversation.hasArchived
|
||||||
@ -1168,8 +1171,8 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchUsers() {
|
private fun fetchUsers(query: String = "") {
|
||||||
contactsViewModel.getContactsFromSearchParams()
|
contactsViewModel.getContactsFromSearchParams(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleHttpExceptions(throwable: Throwable) {
|
private fun handleHttpExceptions(throwable: Throwable) {
|
||||||
@ -1369,12 +1372,15 @@ class ConversationsListActivity :
|
|||||||
clearMessageSearchResults()
|
clearMessageSearchResults()
|
||||||
binding.noArchivedConversationLayout.visibility = View.GONE
|
binding.noArchivedConversationLayout.visibility = View.GONE
|
||||||
|
|
||||||
|
fetchUsers(filter)
|
||||||
|
|
||||||
if (hasFilterEnabled()) {
|
if (hasFilterEnabled()) {
|
||||||
adapter?.updateDataSet(conversationItems)
|
adapter?.updateDataSet(conversationItems)
|
||||||
adapter?.setFilter(filter)
|
adapter?.setFilter(filter)
|
||||||
adapter?.filterItems()
|
adapter?.filterItems()
|
||||||
adapter?.updateDataSet(filterableConversationItems)
|
adapter?.updateDataSet(filterableConversationItems)
|
||||||
} else {
|
} else {
|
||||||
|
adapter?.updateDataSet(searchableConversationItems)
|
||||||
adapter?.setFilter(filter)
|
adapter?.setFilter(filter)
|
||||||
adapter?.filterItems()
|
adapter?.filterItems()
|
||||||
}
|
}
|
||||||
@ -1389,9 +1395,10 @@ class ConversationsListActivity :
|
|||||||
|
|
||||||
private fun resetSearchResults() {
|
private fun resetSearchResults() {
|
||||||
clearMessageSearchResults()
|
clearMessageSearchResults()
|
||||||
|
adapter?.updateDataSet(conversationItems)
|
||||||
adapter?.setFilter("")
|
adapter?.setFilter("")
|
||||||
adapter?.filterItems()
|
adapter?.filterItems()
|
||||||
val archiveFilterOn = filterState[FilterConversationFragment.ARCHIVE] ?: false
|
val archiveFilterOn = filterState[ARCHIVE] ?: false
|
||||||
if (archiveFilterOn && adapter!!.isEmpty) {
|
if (archiveFilterOn && adapter!!.isEmpty) {
|
||||||
binding.noArchivedConversationLayout.visibility = View.VISIBLE
|
binding.noArchivedConversationLayout.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
@ -2134,8 +2141,8 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateFilterState(mention: Boolean, unread: Boolean) {
|
fun updateFilterState(mention: Boolean, unread: Boolean) {
|
||||||
filterState[FilterConversationFragment.MENTION] = mention
|
filterState[MENTION] = mention
|
||||||
filterState[FilterConversationFragment.UNREAD] = unread
|
filterState[UNREAD] = unread
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setFilterableItems(items: MutableList<AbstractFlexibleItem<*>>) {
|
fun setFilterableItems(items: MutableList<AbstractFlexibleItem<*>>) {
|
||||||
|
Loading…
Reference in New Issue
Block a user