iterate on the isSelected value. Let the UI decide how to render.
This commit is contained in:
committed by
Benoit Marty
parent
e74fcde43e
commit
ae00c28c0d
@@ -176,7 +176,7 @@ class DefaultInvitePeoplePresenter @AssistedInject constructor(
|
||||
val isInvited = existingMembership == RoomMembershipState.INVITE
|
||||
InvitableUser(
|
||||
matrixUser = result.matrixUser,
|
||||
isSelected = selectedUsers.value.contains(result.matrixUser) || isJoined || isInvited,
|
||||
isSelected = selectedUsers.value.contains(result.matrixUser),
|
||||
isAlreadyJoined = isJoined,
|
||||
isAlreadyInvited = isInvited,
|
||||
isUnresolved = result.isUnresolved,
|
||||
|
||||
@@ -127,10 +127,9 @@ private fun InvitePeopleSearchBar(
|
||||
|
||||
LazyColumn {
|
||||
itemsIndexed(results) { index, invitableUser ->
|
||||
val notInvitedOrJoined =
|
||||
!(invitableUser.isAlreadyInvited || invitableUser.isAlreadyJoined)
|
||||
val isUnresolved = invitableUser.isUnresolved && notInvitedOrJoined
|
||||
val enabled = isUnresolved || notInvitedOrJoined
|
||||
val invitedOrJoined = invitableUser.isAlreadyInvited || invitableUser.isAlreadyJoined
|
||||
val isUnresolved = invitableUser.isUnresolved && !invitedOrJoined
|
||||
val enabled = isUnresolved || !invitedOrJoined
|
||||
val data = if (isUnresolved) {
|
||||
CheckableUserRowData.Unresolved(
|
||||
avatarData = invitableUser.matrixUser.getAvatarData(AvatarSize.UserListItem),
|
||||
@@ -152,7 +151,7 @@ private fun InvitePeopleSearchBar(
|
||||
)
|
||||
}
|
||||
CheckableUserRow(
|
||||
checked = invitableUser.isSelected,
|
||||
checked = invitableUser.isSelected || invitedOrJoined,
|
||||
enabled = enabled,
|
||||
data = data,
|
||||
onCheckedChange = { onToggleUser(invitableUser.matrixUser) },
|
||||
|
||||
@@ -142,7 +142,7 @@ internal class DefaultInvitePeoplePresenterTest {
|
||||
} else {
|
||||
assertThat(users[index].isAlreadyJoined).isTrue()
|
||||
}
|
||||
assertThat(users[index].isSelected).isTrue()
|
||||
assertThat(users[index].isSelected).isFalse()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -323,9 +323,9 @@ internal class DefaultInvitePeoplePresenterTest {
|
||||
assertThat(shouldBeSelectedUser).isNotNull()
|
||||
assertThat(shouldBeSelectedUser?.isSelected).isTrue()
|
||||
|
||||
// All the others are selected since their membership is joined or invited
|
||||
// And no others are
|
||||
val allOtherUsers = users.minus(shouldBeSelectedUser!!)
|
||||
assertThat(allOtherUsers.all { it.isSelected }).isTrue()
|
||||
assertThat(allOtherUsers.none { it.isSelected }).isTrue()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,9 +372,9 @@ internal class DefaultInvitePeoplePresenterTest {
|
||||
assertThat(shouldBeSelectedUser).isNotNull()
|
||||
assertThat(shouldBeSelectedUser?.isSelected).isTrue()
|
||||
|
||||
// All the others are selected since their membership is joined or invited
|
||||
// And no others are
|
||||
val allOtherUsers = users.minus(shouldBeSelectedUser!!)
|
||||
assertThat(allOtherUsers.all { it.isSelected }).isTrue()
|
||||
assertThat(allOtherUsers.none { it.isSelected }).isTrue()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user