Skip to content

Commit

Permalink
Merge pull request #4088 from nextcloud/issue-4080-search-bug-convers…
Browse files Browse the repository at this point in the history
…ation

Fix conversation search functionality and highlighting
  • Loading branch information
sowjanyakch authored Aug 26, 2024
2 parents 2f22195 + 64ac46e commit fa4bfbc
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,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 @@ -538,6 +539,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 @@ -618,17 +625,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 fa4bfbc

Please sign in to comment.