Check if user is not already selected
This commit is contained in:
parent
ddb49da7f3
commit
841a24a3a4
2 changed files with 4 additions and 6 deletions
|
|
@ -26,7 +26,9 @@ class UserListDataStore @Inject constructor() {
|
|||
private val selectedUsers: MutableStateFlow<List<MatrixUser>> = MutableStateFlow(emptyList())
|
||||
|
||||
fun selectUser(user: MatrixUser) {
|
||||
selectedUsers.tryEmit(selectedUsers.value.plus(user))
|
||||
if (user !in selectedUsers.value) {
|
||||
selectedUsers.tryEmit(selectedUsers.value.plus(user))
|
||||
}
|
||||
}
|
||||
|
||||
fun removeUserFromSelection(user: MatrixUser) {
|
||||
|
|
|
|||
|
|
@ -72,11 +72,7 @@ class DefaultUserListPresenter @AssistedInject constructor(
|
|||
when (event) {
|
||||
is UserListEvents.OnSearchActiveChanged -> isSearchActive = event.active
|
||||
is UserListEvents.UpdateSearchQuery -> searchQuery = event.query
|
||||
is UserListEvents.AddToSelection -> {
|
||||
if (event.matrixUser !in selectedUsers.value) {
|
||||
userListDataStore.selectUser(event.matrixUser)
|
||||
}
|
||||
}
|
||||
is UserListEvents.AddToSelection -> userListDataStore.selectUser(event.matrixUser)
|
||||
is UserListEvents.RemoveFromSelection -> userListDataStore.removeUserFromSelection(event.matrixUser)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue