Skip to content

Commit

Permalink
Merge pull request #4116 from nextcloud/backport/4088/stable-20.0
Browse files Browse the repository at this point in the history
[stable-20.0] Fix conversation search functionality and highlighting
  • Loading branch information
sowjanyakch authored Aug 26, 2024
2 parents a849249 + 420451e commit 2063e67
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ class ConversationsListActivity :
conversationsListViewModel.getRoomsFlow
.onEach { list ->
// Update Conversations
conversationItems.clear()
conversationItemsWithHeader.clear()
conversationItems.clear() // fixme remove this
for (conversation in list) {
addToConversationItems(conversation)
}
Expand Down Expand Up @@ -539,6 +540,12 @@ class ConversationsListActivity :
if (searchManager != null) {
searchView!!.setSearchableInfo(searchManager.getSearchableInfo(componentName))
}
initSearchDisposable()
}
}

private fun initSearchDisposable() {
if (searchViewDisposable == null || searchViewDisposable?.isDisposed == true) {
searchViewDisposable = observeSearchView(searchView!!)
.debounce { query: String? ->
if (TextUtils.isEmpty(query)) {
Expand Down Expand Up @@ -619,17 +626,31 @@ class ConversationsListActivity :
showSearchView(searchView, searchItem)
viewThemeUtils.platform.themeStatusBar(this)
}
searchView!!.setOnCloseListener {
searchView!!.findViewById<View>(R.id.search_close_btn).setOnClickListener {
if (TextUtils.isEmpty(searchView!!.query.toString())) {
searchView!!.onActionViewCollapsed()
viewThemeUtils.platform.resetStatusBar(this)
} else {
searchView!!.post { searchView!!.setQuery(TAG, true) }
resetSearchResults()
searchView!!.setQuery("", false)
}
true
}

searchView!!.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(p0: String?): Boolean {
initSearchDisposable()
return true
}

override fun onQueryTextChange(p0: String?): Boolean {
this@ConversationsListActivity.onQueryTextChange(p0)
return true
}
})

searchItem!!.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
override fun onMenuItemActionExpand(item: MenuItem): Boolean {
initSearchDisposable()
adapter!!.setHeadersShown(true)
if (!filterState.containsValue(true)) filterableConversationItems = searchableConversationItems
adapter!!.updateDataSet(filterableConversationItems, false)
Expand Down

0 comments on commit 2063e67

Please sign in to comment.