Skip to content
Snippets Groups Projects
Commit cdd60463 authored by Taras's avatar Taras
Browse files

Filter ignored users from people tab

parent 7d70bf51
No related branches found
No related tags found
No related merge requests found
......@@ -45,25 +45,34 @@ class PeopleDataSource @Inject constructor(
suspend fun getPeopleList(query: String) = combine(
searchUserDataSource.searchKnownUsers(query),
searchUserDataSource.searchSuggestions(query),
getIgnoredUserFlow(),
getProfileRoomMembersKnockFlow()
) { knowUsers, suggestions, requests ->
withContext(Dispatchers.IO) { buildList(knowUsers, suggestions, requests) }
) { knowUsers, suggestions, ignoredUsers, requests ->
withContext(Dispatchers.IO) { buildList(knowUsers, suggestions, ignoredUsers, requests) }
}.distinctUntilChanged()
suspend fun refreshRoomMembers() {
searchUserDataSource.loadAllRoomMembersIfNeeded()
}
private fun getIgnoredUserFlow() =
session?.userService()?.getIgnoredUsersLive()?.asFlow() ?: flowOf()
private fun buildList(
knowUsers: List<User>,
suggestions: List<User>,
ignoredUsers: List<User>,
requests: List<KnockRequestListItem>
): List<PeopleListItem> {
val ignoredUsersIds = ignoredUsers.map { it.userId }.toSet()
val uniqueItemsList = mutableListOf<PeopleListItem>().apply {
addAll(requests.map { it.toPeopleRequestListItem() })
addAll(knowUsers.map { it.toPeopleUserListItem(getKnownUserItemType(it.userId)) })
addAll(suggestions.map { it.toPeopleUserListItem(PeopleItemType.Suggestion) })
}.distinctBy { it.id }.filterNot { it.id == session?.myUserId }
}
.distinctBy { it.id }
.filterNot { it.id == session?.myUserId || ignoredUsersIds.contains(it.id) }
return mutableListOf<PeopleListItem>().apply {
addSection(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment