Browse Source

The name ConfirmingBanUser was wrong since it was used to confirm a unban action. Better to keep a generic name, in case this class is used for any other action.

pull/3671/head
Benoit Marty 2 days ago
parent
commit
b33b423a19
  1. 2
      features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/ConfirmingRoomMemberAction.kt
  2. 4
      features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationPresenter.kt
  3. 2
      features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationStateProvider.kt
  4. 2
      features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationView.kt
  5. 6
      features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/members/moderation/RoomMembersModerationPresenterTest.kt
  6. 6
      features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/members/moderation/RoomMembersModerationViewTest.kt

2
features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/ConfirmingBanUser.kt → features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/ConfirmingRoomMemberAction.kt

@ -10,6 +10,6 @@ package io.element.android.features.roomdetails.impl.members.moderation
import io.element.android.libraries.architecture.AsyncAction import io.element.android.libraries.architecture.AsyncAction
import io.element.android.libraries.matrix.api.room.RoomMember import io.element.android.libraries.matrix.api.room.RoomMember
data class ConfirmingBanUser( data class ConfirmingRoomMemberAction(
val roomMember: RoomMember, val roomMember: RoomMember,
) : AsyncAction.Confirming ) : AsyncAction.Confirming

4
features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationPresenter.kt

@ -88,8 +88,10 @@ class RoomMembersModerationPresenter @Inject constructor(
when (event) { when (event) {
is RoomMembersModerationEvents.SelectRoomMember -> { is RoomMembersModerationEvents.SelectRoomMember -> {
if (event.roomMember.membership == RoomMembershipState.BAN && canBan) { if (event.roomMember.membership == RoomMembershipState.BAN && canBan) {
unbanUserAsyncAction.value = ConfirmingBanUser(event.roomMember) // In this case the view will render a dialog to confirm the unbanning of the user
unbanUserAsyncAction.value = ConfirmingRoomMemberAction(event.roomMember)
} else { } else {
// In this case the view will render a bottom sheet.
selectedMember = event.roomMember selectedMember = event.roomMember
} }
} }

2
features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationStateProvider.kt

@ -60,7 +60,7 @@ class RoomMembersModerationStateProvider : PreviewParameterProvider<RoomMembersM
), ),
aRoomMembersModerationState( aRoomMembersModerationState(
selectedRoomMember = anAlice(), selectedRoomMember = anAlice(),
unbanUserAsyncAction = ConfirmingBanUser(anAlice()), unbanUserAsyncAction = ConfirmingRoomMemberAction(anAlice()),
), ),
aRoomMembersModerationState( aRoomMembersModerationState(
kickUserAsyncAction = AsyncAction.Success(Unit), kickUserAsyncAction = AsyncAction.Success(Unit),

2
features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationView.kt

@ -147,7 +147,7 @@ fun RoomMembersModerationView(
when (val action = state.unbanUserAsyncAction) { when (val action = state.unbanUserAsyncAction) {
is AsyncAction.Confirming -> { is AsyncAction.Confirming -> {
if (action is ConfirmingBanUser) { if (action is ConfirmingRoomMemberAction) {
ConfirmationDialog( ConfirmationDialog(
title = stringResource(R.string.screen_room_member_list_manage_member_unban_title), title = stringResource(R.string.screen_room_member_list_manage_member_unban_title),
content = stringResource(R.string.screen_room_member_list_manage_member_unban_message), content = stringResource(R.string.screen_room_member_list_manage_member_unban_message),

6
features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/members/moderation/RoomMembersModerationPresenterTest.kt

@ -14,7 +14,7 @@ import com.google.common.truth.Truth.assertThat
import im.vector.app.features.analytics.plan.RoomModeration import im.vector.app.features.analytics.plan.RoomModeration
import io.element.android.features.roomdetails.impl.members.aRoomMember import io.element.android.features.roomdetails.impl.members.aRoomMember
import io.element.android.features.roomdetails.impl.members.aVictor import io.element.android.features.roomdetails.impl.members.aVictor
import io.element.android.features.roomdetails.impl.members.moderation.ConfirmingBanUser import io.element.android.features.roomdetails.impl.members.moderation.ConfirmingRoomMemberAction
import io.element.android.features.roomdetails.impl.members.moderation.ModerationAction import io.element.android.features.roomdetails.impl.members.moderation.ModerationAction
import io.element.android.features.roomdetails.impl.members.moderation.RoomMembersModerationEvents import io.element.android.features.roomdetails.impl.members.moderation.RoomMembersModerationEvents
import io.element.android.features.roomdetails.impl.members.moderation.RoomMembersModerationPresenter import io.element.android.features.roomdetails.impl.members.moderation.RoomMembersModerationPresenter
@ -153,7 +153,7 @@ class RoomMembersModerationPresenterTest {
awaitItem().eventSink(RoomMembersModerationEvents.SelectRoomMember(selectedMember)) awaitItem().eventSink(RoomMembersModerationEvents.SelectRoomMember(selectedMember))
with(awaitItem()) { with(awaitItem()) {
assertThat(selectedRoomMember).isNull() assertThat(selectedRoomMember).isNull()
assertThat(unbanUserAsyncAction).isEqualTo(ConfirmingBanUser(selectedMember)) assertThat(unbanUserAsyncAction).isEqualTo(ConfirmingRoomMemberAction(selectedMember))
} }
} }
} }
@ -244,7 +244,7 @@ class RoomMembersModerationPresenterTest {
val confirmingState = awaitItem() val confirmingState = awaitItem()
assertThat(confirmingState.selectedRoomMember).isNull() assertThat(confirmingState.selectedRoomMember).isNull()
assertThat(confirmingState.actions).isEmpty() assertThat(confirmingState.actions).isEmpty()
assertThat(confirmingState.unbanUserAsyncAction).isEqualTo(ConfirmingBanUser(selectedMember)) assertThat(confirmingState.unbanUserAsyncAction).isEqualTo(ConfirmingRoomMemberAction(selectedMember))
// Confirms unban // Confirms unban
confirmingState.eventSink(RoomMembersModerationEvents.UnbanUser(selectedMember.userId)) confirmingState.eventSink(RoomMembersModerationEvents.UnbanUser(selectedMember.userId))
assertThat(awaitItem().unbanUserAsyncAction).isEqualTo(AsyncAction.Loading) assertThat(awaitItem().unbanUserAsyncAction).isEqualTo(AsyncAction.Loading)

6
features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/members/moderation/RoomMembersModerationViewTest.kt

@ -13,7 +13,7 @@ import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import io.element.android.features.roomdetails.impl.R import io.element.android.features.roomdetails.impl.R
import io.element.android.features.roomdetails.impl.members.anAlice import io.element.android.features.roomdetails.impl.members.anAlice
import io.element.android.features.roomdetails.impl.members.moderation.ConfirmingBanUser import io.element.android.features.roomdetails.impl.members.moderation.ConfirmingRoomMemberAction
import io.element.android.features.roomdetails.impl.members.moderation.ModerationAction import io.element.android.features.roomdetails.impl.members.moderation.ModerationAction
import io.element.android.features.roomdetails.impl.members.moderation.RoomMembersModerationEvents import io.element.android.features.roomdetails.impl.members.moderation.RoomMembersModerationEvents
import io.element.android.features.roomdetails.impl.members.moderation.RoomMembersModerationState import io.element.android.features.roomdetails.impl.members.moderation.RoomMembersModerationState
@ -165,7 +165,7 @@ class RoomMembersModerationViewTest {
val roomMember = anAlice() val roomMember = anAlice()
val state = aRoomMembersModerationState( val state = aRoomMembersModerationState(
selectedRoomMember = roomMember, selectedRoomMember = roomMember,
unbanUserAsyncAction = ConfirmingBanUser(roomMember), unbanUserAsyncAction = ConfirmingRoomMemberAction(roomMember),
eventSink = eventsRecorder eventSink = eventsRecorder
) )
rule.setRoomMembersModerationView( rule.setRoomMembersModerationView(
@ -182,7 +182,7 @@ class RoomMembersModerationViewTest {
val roomMember = anAlice() val roomMember = anAlice()
val state = aRoomMembersModerationState( val state = aRoomMembersModerationState(
selectedRoomMember = roomMember, selectedRoomMember = roomMember,
unbanUserAsyncAction = ConfirmingBanUser(roomMember), unbanUserAsyncAction = ConfirmingRoomMemberAction(roomMember),
eventSink = eventsRecorder eventSink = eventsRecorder
) )
rule.setRoomMembersModerationView( rule.setRoomMembersModerationView(

Loading…
Cancel
Save