Skip to content

Commit

Permalink
feat: improve username search in UsernameRequestsFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Nov 13, 2024
1 parent a36f41c commit 6df16b5
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,20 @@ class UsernameRequestsFragment : Fragment(R.layout.fragment_username_requests) {
binding.requestGroups.scrollToPosition(scrollPosition)
}

// private fun setVotes(adapter: UsernameRequestGroupAdapter, votes: List<UsernameVote>) {
// adapter.updateVotes(votes)
// }

/**
* Returns a list of [UsernameRequestGroupView] where the username of the group or the label or normalizedLabel
* of any related request contains [query] text.
*/
private fun filterByQuery(items: List<UsernameRequestGroupView>, query: String?): List<UsernameRequestGroupView> {
if (query.isNullOrEmpty()) {
return items
}

return items.filter { it.username.startsWith(query, true) }
return items.filter {
it.username.contains(query, true) || it.requests.any {
request -> request.normalizedLabel.contains(query)
}
}
}

private fun populateAppliedFilters(state: FiltersUIState) {
Expand Down

0 comments on commit 6df16b5

Please sign in to comment.