From fb52657b122806fbd869638e0e3a0d2fb8e2a294 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 14 Oct 2024 10:49:55 +0200 Subject: [PATCH 1/4] Let `AsyncAction.Confirming` be an interface, with a `AsyncAction.ConfirmingNoParams` data object. This will allow inheritance of `AsyncAction.Confirming` with parameter(s). --- .../logout/impl/AccountDeactivationPresenter.kt | 2 +- .../logout/impl/AccountDeactivationStateProvider.kt | 2 +- .../logout/impl/ui/AccountDeactivationActionDialog.kt | 2 +- .../logout/impl/AccountDeactivationPresenterTest.kt | 6 +++--- .../logout/impl/AccountDeactivationViewTest.kt | 2 +- .../api/response/AcceptDeclineInviteStateProvider.kt | 4 ++-- .../impl/response/AcceptDeclineInvitePresenter.kt | 2 +- .../features/lockscreen/impl/unlock/PinUnlockView.kt | 2 +- .../login/impl/screens/qrcode/scan/QrCodeScanView.kt | 2 +- .../logout/api/direct/DirectLogoutStateProvider.kt | 2 +- .../android/features/logout/impl/LogoutPresenter.kt | 2 +- .../features/logout/impl/LogoutStateProvider.kt | 2 +- .../logout/impl/direct/DirectLogoutPresenter.kt | 2 +- .../features/logout/impl/ui/LogoutActionDialog.kt | 2 +- .../features/logout/impl/LogoutPresenterTest.kt | 8 ++++---- .../android/features/logout/impl/LogoutViewTest.kt | 2 +- .../logout/impl/direct/DefaultDirectLogoutViewTest.kt | 6 +++--- .../logout/impl/direct/DirectLogoutPresenterTest.kt | 8 ++++---- .../impl/blockedusers/BlockedUsersPresenter.kt | 2 +- .../blockedusers/BlockedUsersStatePreviewProvider.kt | 2 +- .../impl/blockedusers/BlockedUserViewTest.kt | 4 ++-- .../moderation/RoomMembersModerationPresenter.kt | 6 +++--- .../RoomMembersModerationStatePreviewProvider.kt | 4 ++-- .../RolesAndPermissionsPresenter.kt | 4 ++-- .../RolesAndPermissionsStateProvider.kt | 4 ++-- .../changeroles/ChangeRolesPresenter.kt | 4 ++-- .../changeroles/ChangeRolesStateProvider.kt | 4 ++-- .../permissions/ChangeRoomPermissionsPresenter.kt | 2 +- .../ChangeRoomPermissionsStatePreviewProvider.kt | 2 +- .../moderation/RoomMembersModerationPresenterTest.kt | 4 ++-- .../moderation/RoomMembersModerationViewTest.kt | 8 ++++---- .../RolesAndPermissionPresenterTest.kt | 2 +- .../rolesandpermissions/RolesAndPermissionsViewTest.kt | 10 +++++----- .../changeroles/ChangeRolesPresenterTest.kt | 8 ++++---- .../changeroles/ChangeRolesViewTest.kt | 8 ++++---- .../permissions/ChangeRoomPermissionsPresenterTest.kt | 2 +- .../permissions/ChangeRoomPermissionsViewTest.kt | 4 ++-- .../impl/disable/SecureBackupDisablePresenter.kt | 2 +- .../impl/disable/SecureBackupDisableStateProvider.kt | 2 +- .../impl/disable/SecureBackupDisablePresenterTest.kt | 6 +++--- .../verifysession/impl/VerifySelfSessionView.kt | 2 +- .../android/libraries/architecture/AsyncAction.kt | 6 ++++-- .../components/async/AsyncActionProvider.kt | 2 +- .../designsystem/components/async/AsyncActionView.kt | 2 +- .../troubleshoot/impl/TroubleshootNotificationsView.kt | 4 ++-- .../troubleshoot/impl/TroubleshootTestSuite.kt | 2 +- 46 files changed, 86 insertions(+), 84 deletions(-) diff --git a/features/deactivation/impl/src/main/kotlin/io/element/android/features/logout/impl/AccountDeactivationPresenter.kt b/features/deactivation/impl/src/main/kotlin/io/element/android/features/logout/impl/AccountDeactivationPresenter.kt index 8f0e895524..0cadab231f 100644 --- a/features/deactivation/impl/src/main/kotlin/io/element/android/features/logout/impl/AccountDeactivationPresenter.kt +++ b/features/deactivation/impl/src/main/kotlin/io/element/android/features/logout/impl/AccountDeactivationPresenter.kt @@ -51,7 +51,7 @@ class AccountDeactivationPresenter @Inject constructor( action ) } else { - action.value = AsyncAction.Confirming + action.value = AsyncAction.ConfirmingNoParams } AccountDeactivationEvents.CloseDialogs -> { action.value = AsyncAction.Uninitialized diff --git a/features/deactivation/impl/src/main/kotlin/io/element/android/features/logout/impl/AccountDeactivationStateProvider.kt b/features/deactivation/impl/src/main/kotlin/io/element/android/features/logout/impl/AccountDeactivationStateProvider.kt index 07ef6590bb..5de54fe86f 100644 --- a/features/deactivation/impl/src/main/kotlin/io/element/android/features/logout/impl/AccountDeactivationStateProvider.kt +++ b/features/deactivation/impl/src/main/kotlin/io/element/android/features/logout/impl/AccountDeactivationStateProvider.kt @@ -20,7 +20,7 @@ open class AccountDeactivationStateProvider : PreviewParameterProvider Unit - AsyncAction.Confirming -> + is AsyncAction.Confirming -> AccountDeactivationConfirmationDialog( onSubmitClick = onConfirmClick, onDismiss = onDismissDialog diff --git a/features/deactivation/impl/src/test/kotlin/io/element/android/features/logout/impl/AccountDeactivationPresenterTest.kt b/features/deactivation/impl/src/test/kotlin/io/element/android/features/logout/impl/AccountDeactivationPresenterTest.kt index b34ac2f391..eee88bd615 100644 --- a/features/deactivation/impl/src/test/kotlin/io/element/android/features/logout/impl/AccountDeactivationPresenterTest.kt +++ b/features/deactivation/impl/src/test/kotlin/io/element/android/features/logout/impl/AccountDeactivationPresenterTest.kt @@ -74,7 +74,7 @@ class AccountDeactivationPresenterTest { skipItems(1) initialState.eventSink(AccountDeactivationEvents.DeactivateAccount(isRetry = false)) val updatedState = awaitItem() - assertThat(updatedState.accountDeactivationAction).isEqualTo(AsyncAction.Confirming) + assertThat(updatedState.accountDeactivationAction).isEqualTo(AsyncAction.ConfirmingNoParams) updatedState.eventSink(AccountDeactivationEvents.DeactivateAccount(isRetry = false)) val updatedState2 = awaitItem() assertThat(updatedState2.accountDeactivationAction).isEqualTo(AsyncAction.Loading) @@ -102,7 +102,7 @@ class AccountDeactivationPresenterTest { skipItems(2) initialState.eventSink(AccountDeactivationEvents.DeactivateAccount(isRetry = false)) val updatedState = awaitItem() - assertThat(updatedState.accountDeactivationAction).isEqualTo(AsyncAction.Confirming) + assertThat(updatedState.accountDeactivationAction).isEqualTo(AsyncAction.ConfirmingNoParams) updatedState.eventSink(AccountDeactivationEvents.DeactivateAccount(isRetry = false)) val updatedState2 = awaitItem() assertThat(updatedState2.accountDeactivationAction).isEqualTo(AsyncAction.Loading) @@ -135,7 +135,7 @@ class AccountDeactivationPresenterTest { skipItems(2) initialState.eventSink(AccountDeactivationEvents.DeactivateAccount(isRetry = false)) val updatedState = awaitItem() - assertThat(updatedState.accountDeactivationAction).isEqualTo(AsyncAction.Confirming) + assertThat(updatedState.accountDeactivationAction).isEqualTo(AsyncAction.ConfirmingNoParams) updatedState.eventSink(AccountDeactivationEvents.DeactivateAccount(isRetry = false)) val updatedState2 = awaitItem() assertThat(updatedState2.accountDeactivationAction).isEqualTo(AsyncAction.Loading) diff --git a/features/deactivation/impl/src/test/kotlin/io/element/android/features/logout/impl/AccountDeactivationViewTest.kt b/features/deactivation/impl/src/test/kotlin/io/element/android/features/logout/impl/AccountDeactivationViewTest.kt index 06d27e463b..a7c616e4cf 100644 --- a/features/deactivation/impl/src/test/kotlin/io/element/android/features/logout/impl/AccountDeactivationViewTest.kt +++ b/features/deactivation/impl/src/test/kotlin/io/element/android/features/logout/impl/AccountDeactivationViewTest.kt @@ -71,7 +71,7 @@ class AccountDeactivationViewTest { deactivateFormState = aDeactivateFormState( password = A_PASSWORD, ), - accountDeactivationAction = AsyncAction.Confirming, + accountDeactivationAction = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder, ), ) diff --git a/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteStateProvider.kt b/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteStateProvider.kt index dcf7238b00..4c377590e6 100644 --- a/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteStateProvider.kt +++ b/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteStateProvider.kt @@ -20,13 +20,13 @@ open class AcceptDeclineInviteStateProvider : PreviewParameterProvider { currentInvite = Optional.of(event.invite) - declinedAction.value = AsyncAction.Confirming + declinedAction.value = AsyncAction.ConfirmingNoParams } is InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite -> { diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockView.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockView.kt index 8667b3806a..f0a611d56f 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockView.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/PinUnlockView.kt @@ -96,7 +96,7 @@ fun PinUnlockView( latestOnSuccessLogout(state.signOutAction.data) } } - AsyncAction.Confirming, + is AsyncAction.Confirming, is AsyncAction.Failure, AsyncAction.Uninitialized -> Unit } diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/scan/QrCodeScanView.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/scan/QrCodeScanView.kt index 2b38deed70..d32f66cebd 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/scan/QrCodeScanView.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/qrcode/scan/QrCodeScanView.kt @@ -189,7 +189,7 @@ private fun ColumnScope.Buttons( } } AsyncAction.Uninitialized, - AsyncAction.Confirming -> Unit + is AsyncAction.Confirming -> Unit } } } diff --git a/features/logout/api/src/main/kotlin/io/element/android/features/logout/api/direct/DirectLogoutStateProvider.kt b/features/logout/api/src/main/kotlin/io/element/android/features/logout/api/direct/DirectLogoutStateProvider.kt index 62b52dbde8..b59eb087ca 100644 --- a/features/logout/api/src/main/kotlin/io/element/android/features/logout/api/direct/DirectLogoutStateProvider.kt +++ b/features/logout/api/src/main/kotlin/io/element/android/features/logout/api/direct/DirectLogoutStateProvider.kt @@ -14,7 +14,7 @@ open class DirectLogoutStateProvider : PreviewParameterProvider get() = sequenceOf( aDirectLogoutState(), - aDirectLogoutState(logoutAction = AsyncAction.Confirming), + aDirectLogoutState(logoutAction = AsyncAction.ConfirmingNoParams), aDirectLogoutState(logoutAction = AsyncAction.Loading), aDirectLogoutState(logoutAction = AsyncAction.Failure(Exception("Error"))), aDirectLogoutState(logoutAction = AsyncAction.Success("success")), diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutPresenter.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutPresenter.kt index 65ffa75f02..d3a7e4c34b 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutPresenter.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutPresenter.kt @@ -64,7 +64,7 @@ class LogoutPresenter @Inject constructor( if (logoutAction.value.isConfirming() || event.ignoreSdkError) { localCoroutineScope.logout(logoutAction, event.ignoreSdkError) } else { - logoutAction.value = AsyncAction.Confirming + logoutAction.value = AsyncAction.ConfirmingNoParams } } LogoutEvents.CloseDialogs -> { diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutStateProvider.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutStateProvider.kt index 1f648a51ee..364cdbebef 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutStateProvider.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutStateProvider.kt @@ -21,7 +21,7 @@ open class LogoutStateProvider : PreviewParameterProvider { aLogoutState(isLastDevice = true), aLogoutState(isLastDevice = false, backupUploadState = BackupUploadState.Uploading(66, 200)), aLogoutState(isLastDevice = true, backupUploadState = BackupUploadState.Done), - aLogoutState(logoutAction = AsyncAction.Confirming), + aLogoutState(logoutAction = AsyncAction.ConfirmingNoParams), aLogoutState(logoutAction = AsyncAction.Loading), aLogoutState(logoutAction = AsyncAction.Failure(Exception("Failed to logout"))), aLogoutState(backupUploadState = BackupUploadState.SteadyException(SteadyStateException.Connection("No network"))), diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/direct/DirectLogoutPresenter.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/direct/DirectLogoutPresenter.kt index 4a5fead974..f78efc6cda 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/direct/DirectLogoutPresenter.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/direct/DirectLogoutPresenter.kt @@ -52,7 +52,7 @@ class DirectLogoutPresenter @Inject constructor( if (logoutAction.value.isConfirming() || event.ignoreSdkError) { localCoroutineScope.logout(logoutAction, event.ignoreSdkError) } else { - logoutAction.value = AsyncAction.Confirming + logoutAction.value = AsyncAction.ConfirmingNoParams } } DirectLogoutEvents.CloseDialogs -> { diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/ui/LogoutActionDialog.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/ui/LogoutActionDialog.kt index 44f01e738d..3c43f2e099 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/ui/LogoutActionDialog.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/ui/LogoutActionDialog.kt @@ -29,7 +29,7 @@ fun LogoutActionDialog( when (state) { AsyncAction.Uninitialized -> Unit - AsyncAction.Confirming -> + is AsyncAction.Confirming -> LogoutConfirmationDialog( onSubmitClick = onConfirmClick, onDismiss = onDismissDialog diff --git a/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/LogoutPresenterTest.kt b/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/LogoutPresenterTest.kt index 348f983b66..b1e48838aa 100644 --- a/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/LogoutPresenterTest.kt +++ b/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/LogoutPresenterTest.kt @@ -107,7 +107,7 @@ class LogoutPresenterTest { val initialState = awaitFirstItem() initialState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() - assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.Confirming) + assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) initialState.eventSink.invoke(LogoutEvents.CloseDialogs) val finalState = awaitItem() assertThat(finalState.logoutAction).isEqualTo(AsyncAction.Uninitialized) @@ -123,7 +123,7 @@ class LogoutPresenterTest { val initialState = awaitFirstItem() initialState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() - assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.Confirming) + assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) confirmationState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) @@ -148,7 +148,7 @@ class LogoutPresenterTest { val initialState = awaitFirstItem() initialState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() - assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.Confirming) + assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) confirmationState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) @@ -180,7 +180,7 @@ class LogoutPresenterTest { val initialState = awaitFirstItem() initialState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() - assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.Confirming) + assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) confirmationState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) diff --git a/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/LogoutViewTest.kt b/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/LogoutViewTest.kt index 1621872813..5f59b141f2 100644 --- a/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/LogoutViewTest.kt +++ b/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/LogoutViewTest.kt @@ -48,7 +48,7 @@ class LogoutViewTest { val eventsRecorder = EventsRecorder() rule.setLogoutView( aLogoutState( - logoutAction = AsyncAction.Confirming, + logoutAction = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder ), ) diff --git a/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/direct/DefaultDirectLogoutViewTest.kt b/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/direct/DefaultDirectLogoutViewTest.kt index 9daf3cdf63..c859684e31 100644 --- a/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/direct/DefaultDirectLogoutViewTest.kt +++ b/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/direct/DefaultDirectLogoutViewTest.kt @@ -36,7 +36,7 @@ class DefaultDirectLogoutViewTest { val eventsRecorder = EventsRecorder() rule.setDefaultDirectLogoutView( state = aDirectLogoutState( - logoutAction = AsyncAction.Confirming, + logoutAction = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder, ) ) @@ -49,7 +49,7 @@ class DefaultDirectLogoutViewTest { val eventsRecorder = EventsRecorder() rule.setDefaultDirectLogoutView( state = aDirectLogoutState( - logoutAction = AsyncAction.Confirming, + logoutAction = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder, ) ) @@ -63,7 +63,7 @@ class DefaultDirectLogoutViewTest { val eventsRecorder = EventsRecorder() rule.setDefaultDirectLogoutView( state = aDirectLogoutState( - logoutAction = AsyncAction.Confirming, + logoutAction = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder, ) ) diff --git a/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/direct/DirectLogoutPresenterTest.kt b/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/direct/DirectLogoutPresenterTest.kt index a490b7b10d..5835686365 100644 --- a/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/direct/DirectLogoutPresenterTest.kt +++ b/features/logout/impl/src/test/kotlin/io/element/android/features/logout/impl/direct/DirectLogoutPresenterTest.kt @@ -88,7 +88,7 @@ class DirectLogoutPresenterTest { val initialState = awaitFirstItem() initialState.eventSink.invoke(DirectLogoutEvents.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() - assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.Confirming) + assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) initialState.eventSink.invoke(DirectLogoutEvents.CloseDialogs) val finalState = awaitItem() assertThat(finalState.logoutAction).isEqualTo(AsyncAction.Uninitialized) @@ -104,7 +104,7 @@ class DirectLogoutPresenterTest { val initialState = awaitFirstItem() initialState.eventSink.invoke(DirectLogoutEvents.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() - assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.Confirming) + assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) confirmationState.eventSink.invoke(DirectLogoutEvents.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) @@ -129,7 +129,7 @@ class DirectLogoutPresenterTest { val initialState = awaitFirstItem() initialState.eventSink.invoke(DirectLogoutEvents.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() - assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.Confirming) + assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) confirmationState.eventSink.invoke(DirectLogoutEvents.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) @@ -161,7 +161,7 @@ class DirectLogoutPresenterTest { val initialState = awaitFirstItem() initialState.eventSink.invoke(DirectLogoutEvents.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() - assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.Confirming) + assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) confirmationState.eventSink.invoke(DirectLogoutEvents.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUsersPresenter.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUsersPresenter.kt index a957986e87..1bf6935f5c 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUsersPresenter.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUsersPresenter.kt @@ -67,7 +67,7 @@ class BlockedUsersPresenter @Inject constructor( when (event) { is BlockedUsersEvents.Unblock -> { pendingUserToUnblock = event.userId - unblockUserAction.value = AsyncAction.Confirming + unblockUserAction.value = AsyncAction.ConfirmingNoParams } BlockedUsersEvents.ConfirmUnblock -> { pendingUserToUnblock?.let { diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUsersStatePreviewProvider.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUsersStatePreviewProvider.kt index 15b6c6e10f..8bf5b026f8 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUsersStatePreviewProvider.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUsersStatePreviewProvider.kt @@ -19,7 +19,7 @@ class BlockedUsersStatePreviewProvider : PreviewParameterProvider() rule.setBlockedUsersView( aBlockedUsersState( - unblockUserAction = AsyncAction.Confirming, + unblockUserAction = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder ), ) @@ -78,7 +78,7 @@ class BlockedUserViewTest { val eventsRecorder = EventsRecorder() rule.setBlockedUsersView( aBlockedUsersState( - unblockUserAction = AsyncAction.Confirming, + unblockUserAction = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder ), ) diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationPresenter.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationPresenter.kt index 0b9e744dd2..97e518fb47 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationPresenter.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationPresenter.kt @@ -77,7 +77,7 @@ class RoomMembersModerationPresenter @Inject constructor( coroutineScope.launch { selectedMember = event.roomMember if (event.roomMember.membership == RoomMembershipState.BAN && canBan()) { - unbanUserAsyncAction.value = AsyncAction.Confirming + unbanUserAsyncAction.value = AsyncAction.ConfirmingNoParams } else { moderationActions = buildList { add(ModerationAction.DisplayProfile(event.roomMember.userId)) @@ -109,7 +109,7 @@ class RoomMembersModerationPresenter @Inject constructor( coroutineScope.banUser(it.userId, banUserAsyncAction) } } else { - banUserAsyncAction.value = AsyncAction.Confirming + banUserAsyncAction.value = AsyncAction.ConfirmingNoParams } } is RoomMembersModerationEvents.UnbanUser -> { @@ -119,7 +119,7 @@ class RoomMembersModerationPresenter @Inject constructor( coroutineScope.unbanUser(it.userId, unbanUserAsyncAction) } } else { - unbanUserAsyncAction.value = AsyncAction.Confirming + unbanUserAsyncAction.value = AsyncAction.ConfirmingNoParams } } is RoomMembersModerationEvents.Reset -> { diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationStatePreviewProvider.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationStatePreviewProvider.kt index d7fb509995..2642cc501a 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationStatePreviewProvider.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/members/moderation/RoomMembersModerationStatePreviewProvider.kt @@ -56,11 +56,11 @@ class RoomMembersModerationStatePreviewProvider : PreviewParameterProvider { - changeOwnRoleAction.value = AsyncAction.Confirming + changeOwnRoleAction.value = AsyncAction.ConfirmingNoParams } is RolesAndPermissionsEvents.CancelPendingAction -> { changeOwnRoleAction.value = AsyncAction.Uninitialized @@ -77,7 +77,7 @@ class RolesAndPermissionsPresenter @Inject constructor( is RolesAndPermissionsEvents.ResetPermissions -> if (resetPermissionsAction.value.isConfirming()) { coroutineScope.resetPermissions(resetPermissionsAction) } else { - resetPermissionsAction.value = AsyncAction.Confirming + resetPermissionsAction.value = AsyncAction.ConfirmingNoParams } } } diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/RolesAndPermissionsStateProvider.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/RolesAndPermissionsStateProvider.kt index 9dbaa3da96..53cd602c8b 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/RolesAndPermissionsStateProvider.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/RolesAndPermissionsStateProvider.kt @@ -18,7 +18,7 @@ class RolesAndPermissionsStateProvider : PreviewParameterProvider { if (role == RoomMember.Role.ADMIN && selectedUsers != usersWithRole && !saveState.value.isConfirming()) { // Confirm adding admin - saveState.value = AsyncAction.Confirming + saveState.value = AsyncAction.ConfirmingNoParams } else if (!saveState.value.isLoading()) { coroutineScope.save(usersWithRole.value, selectedUsers, saveState) } @@ -145,7 +145,7 @@ class ChangeRolesPresenter @AssistedInject constructor( is ChangeRolesEvent.Exit -> { exitState.value = if (exitState.value.isUninitialized() && hasPendingChanges) { // Has pending changes, confirm exit - AsyncAction.Confirming + AsyncAction.ConfirmingNoParams } else { // No pending changes, exit immediately AsyncAction.Success(Unit) diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/changeroles/ChangeRolesStateProvider.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/changeroles/ChangeRolesStateProvider.kt index b48677423e..82a8f0696b 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/changeroles/ChangeRolesStateProvider.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/changeroles/ChangeRolesStateProvider.kt @@ -36,8 +36,8 @@ class ChangeRolesStateProvider : PreviewParameterProvider { searchResults = SearchBarResultState.Results(MembersByRole(aRoomMemberList().take(1).toImmutableList())), selectedUsers = aMatrixUserList().take(1).toImmutableList(), ), - aChangeRolesStateWithSelectedUsers().copy(exitState = AsyncAction.Confirming), - aChangeRolesStateWithSelectedUsers().copy(savingState = AsyncAction.Confirming), + aChangeRolesStateWithSelectedUsers().copy(exitState = AsyncAction.ConfirmingNoParams), + aChangeRolesStateWithSelectedUsers().copy(savingState = AsyncAction.ConfirmingNoParams), aChangeRolesStateWithSelectedUsers().copy(savingState = AsyncAction.Loading), aChangeRolesStateWithSelectedUsers().copy(savingState = AsyncAction.Success(Unit)), aChangeRolesStateWithSelectedUsers().copy(savingState = AsyncAction.Failure(Exception("boom"))), diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsPresenter.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsPresenter.kt index ba69ed2b08..882ca58be1 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsPresenter.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsPresenter.kt @@ -95,7 +95,7 @@ class ChangeRoomPermissionsPresenter @AssistedInject constructor( confirmExitAction = if (!hasChanges || confirmExitAction.isConfirming()) { AsyncAction.Success(Unit) } else { - AsyncAction.Confirming + AsyncAction.ConfirmingNoParams } } is ChangeRoomPermissionsEvent.ResetPendingActions -> { diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsStatePreviewProvider.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsStatePreviewProvider.kt index d6099dc7f8..d916131f30 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsStatePreviewProvider.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsStatePreviewProvider.kt @@ -26,7 +26,7 @@ class ChangeRoomPermissionsStatePreviewProvider : PreviewParameterProvider() rule.setRolesAndPermissionsView( state = aRolesAndPermissionsState( - resetPermissionsAction = AsyncAction.Confirming, + resetPermissionsAction = AsyncAction.ConfirmingNoParams, eventSink = recorder, ), ) @@ -111,7 +111,7 @@ class RolesAndPermissionsViewTest { val recorder = EventsRecorder() rule.setRolesAndPermissionsView( state = aRolesAndPermissionsState( - resetPermissionsAction = AsyncAction.Confirming, + resetPermissionsAction = AsyncAction.ConfirmingNoParams, eventSink = recorder, ), ) @@ -124,7 +124,7 @@ class RolesAndPermissionsViewTest { val recorder = EventsRecorder() rule.setRolesAndPermissionsView( state = aRolesAndPermissionsState( - changeOwnRoleAction = AsyncAction.Confirming, + changeOwnRoleAction = AsyncAction.ConfirmingNoParams, eventSink = recorder, ), ) @@ -138,7 +138,7 @@ class RolesAndPermissionsViewTest { val recorder = EventsRecorder() rule.setRolesAndPermissionsView( state = aRolesAndPermissionsState( - changeOwnRoleAction = AsyncAction.Confirming, + changeOwnRoleAction = AsyncAction.ConfirmingNoParams, eventSink = recorder, ), ) @@ -152,7 +152,7 @@ class RolesAndPermissionsViewTest { val recorder = EventsRecorder() rule.setRolesAndPermissionsView( state = aRolesAndPermissionsState( - changeOwnRoleAction = AsyncAction.Confirming, + changeOwnRoleAction = AsyncAction.ConfirmingNoParams, eventSink = recorder, ), ) diff --git a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/changeroles/ChangeRolesPresenterTest.kt b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/changeroles/ChangeRolesPresenterTest.kt index bff07e06fc..632cd051af 100644 --- a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/changeroles/ChangeRolesPresenterTest.kt +++ b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/changeroles/ChangeRolesPresenterTest.kt @@ -229,7 +229,7 @@ class ChangeRolesPresenterTest { awaitItem().eventSink(ChangeRolesEvent.Exit) val confirmingState = awaitItem() - assertThat(confirmingState.exitState).isEqualTo(AsyncAction.Confirming) + assertThat(confirmingState.exitState).isEqualTo(AsyncAction.ConfirmingNoParams) confirmingState.eventSink(ChangeRolesEvent.CancelExit) assertThat(awaitItem().exitState).isEqualTo(AsyncAction.Uninitialized) @@ -257,7 +257,7 @@ class ChangeRolesPresenterTest { skipItems(1) updatedState.eventSink(ChangeRolesEvent.Exit) - assertThat(awaitItem().exitState).isEqualTo(AsyncAction.Confirming) + assertThat(awaitItem().exitState).isEqualTo(AsyncAction.ConfirmingNoParams) updatedState.eventSink(ChangeRolesEvent.Exit) assertThat(awaitItem().exitState).isEqualTo(AsyncAction.Success(Unit)) @@ -284,7 +284,7 @@ class ChangeRolesPresenterTest { initialState.eventSink(ChangeRolesEvent.UserSelectionToggled(MatrixUser(A_USER_ID_2))) awaitItem().eventSink(ChangeRolesEvent.Save) val confirmingState = awaitItem() - assertThat(confirmingState.savingState).isEqualTo(AsyncAction.Confirming) + assertThat(confirmingState.savingState).isEqualTo(AsyncAction.ConfirmingNoParams) confirmingState.eventSink(ChangeRolesEvent.Save) assertThat(awaitItem().savingState).isEqualTo(AsyncAction.Success(Unit)) @@ -309,7 +309,7 @@ class ChangeRolesPresenterTest { awaitItem().eventSink(ChangeRolesEvent.Save) val confirmingState = awaitItem() - assertThat(confirmingState.savingState).isEqualTo(AsyncAction.Confirming) + assertThat(confirmingState.savingState).isEqualTo(AsyncAction.ConfirmingNoParams) confirmingState.eventSink(ChangeRolesEvent.CancelSave) assertThat(awaitItem().savingState).isEqualTo(AsyncAction.Uninitialized) diff --git a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/changeroles/ChangeRolesViewTest.kt b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/changeroles/ChangeRolesViewTest.kt index 949d102340..8615cb5209 100644 --- a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/changeroles/ChangeRolesViewTest.kt +++ b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/changeroles/ChangeRolesViewTest.kt @@ -140,7 +140,7 @@ class ChangeRolesViewTest { rule.setChangeRolesContent( state = aChangeRolesState( isSearchActive = true, - exitState = AsyncAction.Confirming, + exitState = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder, ), ) @@ -156,7 +156,7 @@ class ChangeRolesViewTest { rule.setChangeRolesContent( state = aChangeRolesState( isSearchActive = true, - exitState = AsyncAction.Confirming, + exitState = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder, ), ) @@ -173,7 +173,7 @@ class ChangeRolesViewTest { state = aChangeRolesState( role = RoomMember.Role.ADMIN, isSearchActive = true, - savingState = AsyncAction.Confirming, + savingState = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder, ), ) @@ -190,7 +190,7 @@ class ChangeRolesViewTest { state = aChangeRolesState( role = RoomMember.Role.ADMIN, isSearchActive = true, - savingState = AsyncAction.Confirming, + savingState = AsyncAction.ConfirmingNoParams, eventSink = eventsRecorder, ), ) diff --git a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/permissions/ChangeRoomPermissionsPresenterTest.kt b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/permissions/ChangeRoomPermissionsPresenterTest.kt index b57d8df1ab..f963ba28c2 100644 --- a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/permissions/ChangeRoomPermissionsPresenterTest.kt +++ b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/permissions/ChangeRoomPermissionsPresenterTest.kt @@ -267,7 +267,7 @@ class ChangeRoomPermissionsPresenterTest { assertThat(awaitItem().hasChanges).isTrue() state.eventSink(ChangeRoomPermissionsEvent.Exit) - assertThat(awaitItem().confirmExitAction).isEqualTo(AsyncAction.Confirming) + assertThat(awaitItem().confirmExitAction).isEqualTo(AsyncAction.ConfirmingNoParams) state.eventSink(ChangeRoomPermissionsEvent.Exit) assertThat(awaitItem().confirmExitAction).isEqualTo(AsyncAction.Success(Unit)) diff --git a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/permissions/ChangeRoomPermissionsViewTest.kt b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/permissions/ChangeRoomPermissionsViewTest.kt index f85e59ea32..a73973609a 100644 --- a/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/permissions/ChangeRoomPermissionsViewTest.kt +++ b/features/roomdetails/impl/src/test/kotlin/io/element/android/features/roomdetails/rolesandpermissions/permissions/ChangeRoomPermissionsViewTest.kt @@ -82,7 +82,7 @@ class ChangeRoomPermissionsViewTest { state = aChangeRoomPermissionsState( section = ChangeRoomPermissionsSection.RoomDetails, hasChanges = true, - confirmExitAction = AsyncAction.Confirming, + confirmExitAction = AsyncAction.ConfirmingNoParams, eventSink = recorder, ), eventsRecorder = recorder, @@ -98,7 +98,7 @@ class ChangeRoomPermissionsViewTest { state = aChangeRoomPermissionsState( section = ChangeRoomPermissionsSection.RoomDetails, hasChanges = true, - confirmExitAction = AsyncAction.Confirming, + confirmExitAction = AsyncAction.ConfirmingNoParams, eventSink = recorder, ), eventsRecorder = recorder, diff --git a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisablePresenter.kt b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisablePresenter.kt index def6e5c2d3..4e661e0a13 100644 --- a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisablePresenter.kt +++ b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisablePresenter.kt @@ -40,7 +40,7 @@ class SecureBackupDisablePresenter @Inject constructor( is SecureBackupDisableEvents.DisableBackup -> if (disableAction.value.isConfirming()) { coroutineScope.disableBackup(disableAction) } else { - disableAction.value = AsyncAction.Confirming + disableAction.value = AsyncAction.ConfirmingNoParams } SecureBackupDisableEvents.DismissDialogs -> { disableAction.value = AsyncAction.Uninitialized diff --git a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisableStateProvider.kt b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisableStateProvider.kt index 8c47eeb0a3..3c2969e35e 100644 --- a/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisableStateProvider.kt +++ b/features/securebackup/impl/src/main/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisableStateProvider.kt @@ -15,7 +15,7 @@ open class SecureBackupDisableStateProvider : PreviewParameterProvider get() = sequenceOf( aSecureBackupDisableState(), - aSecureBackupDisableState(disableAction = AsyncAction.Confirming), + aSecureBackupDisableState(disableAction = AsyncAction.ConfirmingNoParams), aSecureBackupDisableState(disableAction = AsyncAction.Loading), aSecureBackupDisableState(disableAction = AsyncAction.Failure(Exception("Failed to disable"))), // Add other states here diff --git a/features/securebackup/impl/src/test/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisablePresenterTest.kt b/features/securebackup/impl/src/test/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisablePresenterTest.kt index 5a3d1caab9..b0d6399c04 100644 --- a/features/securebackup/impl/src/test/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisablePresenterTest.kt +++ b/features/securebackup/impl/src/test/kotlin/io/element/android/features/securebackup/impl/disable/SecureBackupDisablePresenterTest.kt @@ -47,7 +47,7 @@ class SecureBackupDisablePresenterTest { val initialState = awaitItem() initialState.eventSink(SecureBackupDisableEvents.DisableBackup) val state = awaitItem() - assertThat(state.disableAction).isEqualTo(AsyncAction.Confirming) + assertThat(state.disableAction).isEqualTo(AsyncAction.ConfirmingNoParams) initialState.eventSink(SecureBackupDisableEvents.DismissDialogs) val finalState = awaitItem() assertThat(finalState.disableAction).isEqualTo(AsyncAction.Uninitialized) @@ -64,7 +64,7 @@ class SecureBackupDisablePresenterTest { assertThat(initialState.disableAction).isEqualTo(AsyncAction.Uninitialized) initialState.eventSink(SecureBackupDisableEvents.DisableBackup) val state = awaitItem() - assertThat(state.disableAction).isEqualTo(AsyncAction.Confirming) + assertThat(state.disableAction).isEqualTo(AsyncAction.ConfirmingNoParams) initialState.eventSink(SecureBackupDisableEvents.DisableBackup) val loadingState = awaitItem() assertThat(loadingState.disableAction).isInstanceOf(AsyncAction.Loading::class.java) @@ -88,7 +88,7 @@ class SecureBackupDisablePresenterTest { assertThat(initialState.disableAction).isEqualTo(AsyncAction.Uninitialized) initialState.eventSink(SecureBackupDisableEvents.DisableBackup) val state = awaitItem() - assertThat(state.disableAction).isEqualTo(AsyncAction.Confirming) + assertThat(state.disableAction).isEqualTo(AsyncAction.ConfirmingNoParams) initialState.eventSink(SecureBackupDisableEvents.DisableBackup) val loadingState = awaitItem() assertThat(loadingState.disableAction).isInstanceOf(AsyncAction.Loading::class.java) diff --git a/features/verifysession/impl/src/main/kotlin/io/element/android/features/verifysession/impl/VerifySelfSessionView.kt b/features/verifysession/impl/src/main/kotlin/io/element/android/features/verifysession/impl/VerifySelfSessionView.kt index 2364688c03..5b0c9105ad 100644 --- a/features/verifysession/impl/src/main/kotlin/io/element/android/features/verifysession/impl/VerifySelfSessionView.kt +++ b/features/verifysession/impl/src/main/kotlin/io/element/android/features/verifysession/impl/VerifySelfSessionView.kt @@ -158,7 +158,7 @@ fun VerifySelfSessionView( latestOnSuccessLogout(state.signOutAction.data) } } - AsyncAction.Confirming, + is AsyncAction.Confirming, is AsyncAction.Failure, AsyncAction.Uninitialized -> Unit } diff --git a/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/AsyncAction.kt b/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/AsyncAction.kt index 48fe1d336b..e674a170bd 100644 --- a/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/AsyncAction.kt +++ b/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/AsyncAction.kt @@ -26,7 +26,9 @@ sealed interface AsyncAction { /** * Represents an operation that is currently waiting for user confirmation. */ - data object Confirming : AsyncAction + interface Confirming : AsyncAction + + data object ConfirmingNoParams : Confirming /** * Represents an operation that is currently ongoing. @@ -70,7 +72,7 @@ sealed interface AsyncAction { fun isUninitialized(): Boolean = this == Uninitialized - fun isConfirming(): Boolean = this == Confirming + fun isConfirming(): Boolean = this is Confirming fun isLoading(): Boolean = this == Loading diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionProvider.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionProvider.kt index 97b2dc2bdf..87cb43af75 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionProvider.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionProvider.kt @@ -14,7 +14,7 @@ open class AsyncActionProvider : PreviewParameterProvider> { override val values: Sequence> get() = sequenceOf( AsyncAction.Uninitialized, - AsyncAction.Confirming, + AsyncAction.ConfirmingNoParams, AsyncAction.Loading, AsyncAction.Failure(Exception("An error occurred")), AsyncAction.Success(Unit), diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionView.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionView.kt index be3e2ef7d8..15accbd36c 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionView.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionView.kt @@ -42,7 +42,7 @@ fun AsyncActionView( ) { when (async) { AsyncAction.Uninitialized -> Unit - AsyncAction.Confirming -> confirmationDialog() + is AsyncAction.Confirming -> confirmationDialog() is AsyncAction.Loading -> progressDialog() is AsyncAction.Failure -> { if (onRetry == null) { diff --git a/libraries/troubleshoot/impl/src/main/kotlin/io/element/android/libraries/troubleshoot/impl/TroubleshootNotificationsView.kt b/libraries/troubleshoot/impl/src/main/kotlin/io/element/android/libraries/troubleshoot/impl/TroubleshootNotificationsView.kt index c9b8b1b5fd..5d9220c3bd 100644 --- a/libraries/troubleshoot/impl/src/main/kotlin/io/element/android/libraries/troubleshoot/impl/TroubleshootNotificationsView.kt +++ b/libraries/troubleshoot/impl/src/main/kotlin/io/element/android/libraries/troubleshoot/impl/TroubleshootNotificationsView.kt @@ -122,7 +122,7 @@ private fun ColumnScope.TroubleshootTestView( private fun ColumnScope.TroubleshootNotificationsContent(state: TroubleshootNotificationsState) { when (state.testSuiteState.mainState) { AsyncAction.Loading, - AsyncAction.Confirming, + is AsyncAction.Confirming, is AsyncAction.Success, is AsyncAction.Failure -> { TestSuiteView( @@ -150,7 +150,7 @@ private fun ColumnScope.TroubleshootNotificationsContent(state: TroubleshootNoti }) RunTestButton(state = state) } - AsyncAction.Confirming -> { + is AsyncAction.Confirming -> { ListItem(headlineContent = { Text( text = stringResource(id = R.string.troubleshoot_notifications_screen_waiting) diff --git a/libraries/troubleshoot/impl/src/main/kotlin/io/element/android/libraries/troubleshoot/impl/TroubleshootTestSuite.kt b/libraries/troubleshoot/impl/src/main/kotlin/io/element/android/libraries/troubleshoot/impl/TroubleshootTestSuite.kt index 8bea320553..9b7de10325 100644 --- a/libraries/troubleshoot/impl/src/main/kotlin/io/element/android/libraries/troubleshoot/impl/TroubleshootTestSuite.kt +++ b/libraries/troubleshoot/impl/src/main/kotlin/io/element/android/libraries/troubleshoot/impl/TroubleshootTestSuite.kt @@ -102,7 +102,7 @@ fun List.computeMainState(): AsyncAction AsyncAction.Loading else -> { if (any { it.status is NotificationTroubleshootTestState.Status.WaitingForUser }) { - AsyncAction.Confirming + AsyncAction.ConfirmingNoParams } else if (any { it.status is NotificationTroubleshootTestState.Status.Failure }) { AsyncAction.Failure(Exception("Some tests failed")) } else { From ecd7bb0458f6ea2c082bfbaa92a589ae5d691404 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 14 Oct 2024 11:02:47 +0200 Subject: [PATCH 2/4] AsyncActionView: provide the value to the confirmationDialog lambda. --- .../designsystem/components/async/AsyncActionView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionView.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionView.kt index 15accbd36c..412c033e9f 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionView.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/async/AsyncActionView.kt @@ -34,7 +34,7 @@ fun AsyncActionView( async: AsyncAction, onSuccess: (T) -> Unit, onErrorDismiss: () -> Unit, - confirmationDialog: @Composable () -> Unit = { }, + confirmationDialog: @Composable (AsyncAction.Confirming) -> Unit = { }, progressDialog: @Composable () -> Unit = { AsyncActionViewDefaults.ProgressDialog() }, errorTitle: @Composable (Throwable) -> String = { ErrorDialogDefaults.title }, errorMessage: @Composable (Throwable) -> String = { it.message ?: it.toString() }, @@ -42,7 +42,7 @@ fun AsyncActionView( ) { when (async) { AsyncAction.Uninitialized -> Unit - is AsyncAction.Confirming -> confirmationDialog() + is AsyncAction.Confirming -> confirmationDialog(async) is AsyncAction.Loading -> progressDialog() is AsyncAction.Failure -> { if (onRetry == null) { From 03fd7afdd1dd755e27efb537c0d3368acec3e1b1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 14 Oct 2024 11:19:18 +0200 Subject: [PATCH 3/4] AcceptDeclineInviteState: create ConfirmingDeclineInvite to host InviteData when confirming decline of invite. --- .../api/response/AcceptDeclineInviteState.kt | 2 -- .../AcceptDeclineInviteStateProvider.kt | 13 +++------- .../api/response/ConfirmingDeclineInvite.kt | 14 ++++++++++ .../response/AcceptDeclineInvitePresenter.kt | 24 +++-------------- .../impl/response/AcceptDeclineInviteView.kt | 12 ++++----- .../InternalAcceptDeclineInviteEvents.kt | 3 ++- .../AcceptDeclineInvitePresenterTest.kt | 26 ++++++------------- .../matrix/test/room/FakeInvitedRoom.kt | 5 ++-- 8 files changed, 40 insertions(+), 59 deletions(-) create mode 100644 features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/ConfirmingDeclineInvite.kt diff --git a/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteState.kt b/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteState.kt index e0e369e481..7734b3bb29 100644 --- a/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteState.kt +++ b/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteState.kt @@ -9,10 +9,8 @@ package io.element.android.features.invite.api.response import io.element.android.libraries.architecture.AsyncAction import io.element.android.libraries.matrix.api.core.RoomId -import java.util.Optional data class AcceptDeclineInviteState( - val invite: Optional, val acceptAction: AsyncAction, val declineAction: AsyncAction, val eventSink: (AcceptDeclineInviteEvents) -> Unit, diff --git a/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteStateProvider.kt b/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteStateProvider.kt index 4c377590e6..a4f3695369 100644 --- a/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteStateProvider.kt +++ b/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/AcceptDeclineInviteStateProvider.kt @@ -10,23 +10,20 @@ package io.element.android.features.invite.api.response import androidx.compose.ui.tooling.preview.PreviewParameterProvider import io.element.android.libraries.architecture.AsyncAction import io.element.android.libraries.matrix.api.core.RoomId -import java.util.Optional open class AcceptDeclineInviteStateProvider : PreviewParameterProvider { override val values: Sequence get() = sequenceOf( anAcceptDeclineInviteState(), anAcceptDeclineInviteState( - invite = Optional.of( - InviteData(RoomId("!room:matrix.org"), isDm = true, roomName = "Alice"), + declineAction = ConfirmingDeclineInvite( + InviteData(RoomId("!room:matrix.org"), isDm = true, roomName = "Alice") ), - declineAction = AsyncAction.ConfirmingNoParams, ), anAcceptDeclineInviteState( - invite = Optional.of( - InviteData(RoomId("!room:matrix.org"), isDm = false, roomName = "Some room"), + declineAction = ConfirmingDeclineInvite( + InviteData(RoomId("!room:matrix.org"), isDm = false, roomName = "Some room") ), - declineAction = AsyncAction.ConfirmingNoParams, ), anAcceptDeclineInviteState( acceptAction = AsyncAction.Failure(Throwable("Whoops")), @@ -38,12 +35,10 @@ open class AcceptDeclineInviteStateProvider : PreviewParameterProvider = Optional.empty(), acceptAction: AsyncAction = AsyncAction.Uninitialized, declineAction: AsyncAction = AsyncAction.Uninitialized, eventSink: (AcceptDeclineInviteEvents) -> Unit = {} ) = AcceptDeclineInviteState( - invite = invite, acceptAction = acceptAction, declineAction = declineAction, eventSink = eventSink, diff --git a/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/ConfirmingDeclineInvite.kt b/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/ConfirmingDeclineInvite.kt new file mode 100644 index 0000000000..c2231019c8 --- /dev/null +++ b/features/invite/api/src/main/kotlin/io/element/android/features/invite/api/response/ConfirmingDeclineInvite.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2024 New Vector Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only + * Please see LICENSE in the repository root for full details. + */ + +package io.element.android.features.invite.api.response + +import io.element.android.libraries.architecture.AsyncAction + +data class ConfirmingDeclineInvite( + val inviteData: InviteData, +) : AsyncAction.Confirming diff --git a/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenter.kt b/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenter.kt index 5ebf3cbb76..082120c6f3 100644 --- a/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenter.kt +++ b/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenter.kt @@ -9,15 +9,13 @@ package io.element.android.features.invite.impl.response import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState -import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope -import androidx.compose.runtime.setValue import im.vector.app.features.analytics.plan.JoinedRoom import io.element.android.features.invite.api.response.AcceptDeclineInviteEvents import io.element.android.features.invite.api.response.AcceptDeclineInviteState -import io.element.android.features.invite.api.response.InviteData +import io.element.android.features.invite.api.response.ConfirmingDeclineInvite import io.element.android.libraries.architecture.AsyncAction import io.element.android.libraries.architecture.Presenter import io.element.android.libraries.architecture.runCatchingUpdatingState @@ -29,9 +27,7 @@ import io.element.android.libraries.matrix.api.room.join.JoinRoom import io.element.android.libraries.push.api.notifications.NotificationCleaner import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import java.util.Optional import javax.inject.Inject -import kotlin.jvm.optionals.getOrNull class AcceptDeclineInvitePresenter @Inject constructor( private val client: MatrixClient, @@ -43,35 +39,22 @@ class AcceptDeclineInvitePresenter @Inject constructor( val localCoroutineScope = rememberCoroutineScope() val acceptedAction: MutableState> = remember { mutableStateOf(AsyncAction.Uninitialized) } val declinedAction: MutableState> = remember { mutableStateOf(AsyncAction.Uninitialized) } - var currentInvite by remember { - mutableStateOf>(Optional.empty()) - } fun handleEvents(event: AcceptDeclineInviteEvents) { when (event) { is AcceptDeclineInviteEvents.AcceptInvite -> { - // currentInvite is used to render the decline confirmation dialog - // and to reuse the roomId when the user confirm the rejection of the invitation. - // Just set it to empty here. - currentInvite = Optional.empty() localCoroutineScope.acceptInvite(event.invite.roomId, acceptedAction) } is AcceptDeclineInviteEvents.DeclineInvite -> { - currentInvite = Optional.of(event.invite) - declinedAction.value = AsyncAction.ConfirmingNoParams + declinedAction.value = ConfirmingDeclineInvite(event.invite) } is InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite -> { - declinedAction.value = AsyncAction.Uninitialized - currentInvite.getOrNull()?.let { - localCoroutineScope.declineInvite(it.roomId, declinedAction) - } - currentInvite = Optional.empty() + localCoroutineScope.declineInvite(event.roomId, declinedAction) } is InternalAcceptDeclineInviteEvents.CancelDeclineInvite -> { - currentInvite = Optional.empty() declinedAction.value = AsyncAction.Uninitialized } @@ -86,7 +69,6 @@ class AcceptDeclineInvitePresenter @Inject constructor( } return AcceptDeclineInviteState( - invite = currentInvite, acceptAction = acceptedAction.value, declineAction = declinedAction.value, eventSink = ::handleEvents diff --git a/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInviteView.kt b/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInviteView.kt index 94593d0764..ecbc601352 100644 --- a/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInviteView.kt +++ b/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInviteView.kt @@ -14,6 +14,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import io.element.android.features.invite.api.response.AcceptDeclineInviteState import io.element.android.features.invite.api.response.AcceptDeclineInviteStateProvider +import io.element.android.features.invite.api.response.ConfirmingDeclineInvite import io.element.android.features.invite.api.response.InviteData import io.element.android.features.invite.impl.R import io.element.android.libraries.designsystem.components.async.AsyncActionView @@ -22,7 +23,6 @@ import io.element.android.libraries.designsystem.preview.ElementPreview import io.element.android.libraries.designsystem.preview.PreviewsDayNight import io.element.android.libraries.matrix.api.core.RoomId import io.element.android.libraries.ui.strings.CommonStrings -import kotlin.jvm.optionals.getOrNull @Composable fun AcceptDeclineInviteView( @@ -45,13 +45,13 @@ fun AcceptDeclineInviteView( onErrorDismiss = { state.eventSink(InternalAcceptDeclineInviteEvents.DismissDeclineError) }, - confirmationDialog = { - val invite = state.invite.getOrNull() - if (invite != null) { + confirmationDialog = { confirming -> + // Note: confirming will always be of type ConfirmingDeclineInvite. + if (confirming is ConfirmingDeclineInvite) { DeclineConfirmationDialog( - invite = invite, + invite = confirming.inviteData, onConfirmClick = { - state.eventSink(InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite) + state.eventSink(InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite(confirming.inviteData.roomId)) }, onDismissClick = { state.eventSink(InternalAcceptDeclineInviteEvents.CancelDeclineInvite) diff --git a/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/InternalAcceptDeclineInviteEvents.kt b/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/InternalAcceptDeclineInviteEvents.kt index 779106e1c3..60b96805e6 100644 --- a/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/InternalAcceptDeclineInviteEvents.kt +++ b/features/invite/impl/src/main/kotlin/io/element/android/features/invite/impl/response/InternalAcceptDeclineInviteEvents.kt @@ -8,9 +8,10 @@ package io.element.android.features.invite.impl.response import io.element.android.features.invite.api.response.AcceptDeclineInviteEvents +import io.element.android.libraries.matrix.api.core.RoomId sealed interface InternalAcceptDeclineInviteEvents : AcceptDeclineInviteEvents { - data object ConfirmDeclineInvite : InternalAcceptDeclineInviteEvents + data class ConfirmDeclineInvite(val roomId: RoomId) : InternalAcceptDeclineInviteEvents data object CancelDeclineInvite : InternalAcceptDeclineInviteEvents data object DismissAcceptError : InternalAcceptDeclineInviteEvents data object DismissDeclineError : InternalAcceptDeclineInviteEvents diff --git a/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt b/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt index f194404f8e..6c1057638f 100644 --- a/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt +++ b/features/invite/impl/src/test/kotlin/io/element/android/features/invite/impl/response/AcceptDeclineInvitePresenterTest.kt @@ -10,6 +10,7 @@ package io.element.android.features.invite.impl.response import com.google.common.truth.Truth.assertThat import im.vector.app.features.analytics.plan.JoinedRoom import io.element.android.features.invite.api.response.AcceptDeclineInviteEvents +import io.element.android.features.invite.api.response.ConfirmingDeclineInvite import io.element.android.features.invite.api.response.InviteData import io.element.android.libraries.architecture.AsyncAction import io.element.android.libraries.matrix.api.MatrixClient @@ -33,7 +34,6 @@ import io.element.android.tests.testutils.test import kotlinx.coroutines.test.runTest import org.junit.Rule import org.junit.Test -import java.util.Optional class AcceptDeclineInvitePresenterTest { @get:Rule @@ -46,7 +46,6 @@ class AcceptDeclineInvitePresenterTest { awaitItem().also { state -> assertThat(state.acceptAction).isInstanceOf(AsyncAction.Uninitialized::class.java) assertThat(state.declineAction).isInstanceOf(AsyncAction.Uninitialized::class.java) - assertThat(state.invite).isEqualTo(Optional.empty()) } } } @@ -61,17 +60,13 @@ class AcceptDeclineInvitePresenterTest { AcceptDeclineInviteEvents.DeclineInvite(inviteData) ) } - skipItems(1) awaitItem().also { state -> - assertThat(state.invite).isEqualTo(Optional.of(inviteData)) - assertThat(state.declineAction).isInstanceOf(AsyncAction.Confirming::class.java) + assertThat(state.declineAction).isEqualTo(ConfirmingDeclineInvite(inviteData)) state.eventSink( InternalAcceptDeclineInviteEvents.CancelDeclineInvite ) } - skipItems(1) awaitItem().also { state -> - assertThat(state.invite).isEqualTo(Optional.empty()) assertThat(state.declineAction).isInstanceOf(AsyncAction.Uninitialized::class.java) } } @@ -93,22 +88,20 @@ class AcceptDeclineInvitePresenterTest { AcceptDeclineInviteEvents.DeclineInvite(inviteData) ) } - skipItems(1) awaitItem().also { state -> + assertThat(state.declineAction).isEqualTo(ConfirmingDeclineInvite(inviteData)) state.eventSink( - InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite + InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite(inviteData.roomId) ) } - skipItems(2) + assertThat(awaitItem().declineAction.isLoading()).isTrue() awaitItem().also { state -> assertThat(state.declineAction).isInstanceOf(AsyncAction.Failure::class.java) state.eventSink( InternalAcceptDeclineInviteEvents.DismissDeclineError ) } - skipItems(1) awaitItem().also { state -> - assertThat(state.invite).isEqualTo(Optional.empty()) assertThat(state.declineAction).isInstanceOf(AsyncAction.Uninitialized::class.java) } cancelAndConsumeRemainingEvents() @@ -141,13 +134,13 @@ class AcceptDeclineInvitePresenterTest { AcceptDeclineInviteEvents.DeclineInvite(inviteData) ) } - skipItems(1) awaitItem().also { state -> + assertThat(state.declineAction).isEqualTo(ConfirmingDeclineInvite(inviteData)) state.eventSink( - InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite + InternalAcceptDeclineInviteEvents.ConfirmDeclineInvite(inviteData.roomId) ) } - skipItems(2) + assertThat(awaitItem().declineAction.isLoading()).isTrue() awaitItem().also { state -> assertThat(state.declineAction).isInstanceOf(AsyncAction.Success::class.java) } @@ -173,7 +166,6 @@ class AcceptDeclineInvitePresenterTest { ) } awaitItem().also { state -> - assertThat(state.invite).isEqualTo(Optional.empty()) assertThat(state.acceptAction).isEqualTo(AsyncAction.Loading) } awaitItem().also { state -> @@ -183,7 +175,6 @@ class AcceptDeclineInvitePresenterTest { ) } awaitItem().also { state -> - assertThat(state.invite).isEqualTo(Optional.empty()) assertThat(state.acceptAction).isInstanceOf(AsyncAction.Uninitialized::class.java) } cancelAndConsumeRemainingEvents() @@ -220,7 +211,6 @@ class AcceptDeclineInvitePresenterTest { ) } awaitItem().also { state -> - assertThat(state.invite).isEqualTo(Optional.empty()) assertThat(state.acceptAction).isEqualTo(AsyncAction.Loading) } awaitItem().also { state -> diff --git a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeInvitedRoom.kt b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeInvitedRoom.kt index 3224d1fd2f..06416e2c80 100644 --- a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeInvitedRoom.kt +++ b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeInvitedRoom.kt @@ -13,14 +13,15 @@ import io.element.android.libraries.matrix.api.room.InvitedRoom import io.element.android.libraries.matrix.test.A_ROOM_ID import io.element.android.libraries.matrix.test.A_SESSION_ID import io.element.android.tests.testutils.lambda.lambdaError +import io.element.android.tests.testutils.simulateLongTask class FakeInvitedRoom( override val sessionId: SessionId = A_SESSION_ID, override val roomId: RoomId = A_ROOM_ID, private val declineInviteResult: () -> Result = { lambdaError() } ) : InvitedRoom { - override suspend fun declineInvite(): Result { - return declineInviteResult() + override suspend fun declineInvite(): Result = simulateLongTask { + declineInviteResult() } override fun close() = Unit From ca4f90696486ca60a4082606b9f00c370b066ec1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 14 Oct 2024 11:35:58 +0200 Subject: [PATCH 4/4] Split long lines --- .../ChangeRoomPermissionsStatePreviewProvider.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsStatePreviewProvider.kt b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsStatePreviewProvider.kt index d916131f30..9dcaa15b43 100644 --- a/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsStatePreviewProvider.kt +++ b/features/roomdetails/impl/src/main/kotlin/io/element/android/features/roomdetails/impl/rolesandpermissions/permissions/ChangeRoomPermissionsStatePreviewProvider.kt @@ -26,7 +26,11 @@ class ChangeRoomPermissionsStatePreviewProvider : PreviewParameterProvider