From 116897d64c32454b16b382e2911426c4a3f4656a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 25 Aug 2026 10:05:38 +0200 Subject: [PATCH] `LogoutEvents` -> `LogoutEvent` --- .../impl/{LogoutEvents.kt => LogoutEvent.kt} | 6 ++-- .../features/logout/impl/LogoutPresenter.kt | 6 ++-- .../features/logout/impl/LogoutState.kt | 2 +- .../logout/impl/LogoutStatePreviewParam.kt | 2 +- .../features/logout/impl/LogoutView.kt | 8 +++--- .../logout/impl/LogoutPresenterTest.kt | 20 ++++++------- .../features/logout/impl/LogoutViewTest.kt | 28 +++++++++---------- 7 files changed, 36 insertions(+), 36 deletions(-) rename features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/{LogoutEvents.kt => LogoutEvent.kt} (81%) diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutEvents.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutEvent.kt similarity index 81% rename from features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutEvents.kt rename to features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutEvent.kt index 0822444bea..e23338460c 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutEvents.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutEvent.kt @@ -8,7 +8,7 @@ package io.element.android.features.logout.impl -sealed interface LogoutEvents { - data class Logout(val ignoreSdkError: Boolean) : LogoutEvents - data object CloseDialogs : LogoutEvents +sealed interface LogoutEvent { + data class Logout(val ignoreSdkError: Boolean) : LogoutEvent + data object CloseDialogs : LogoutEvent } 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 8176ed3d28..4ad8a6c78e 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 @@ -74,16 +74,16 @@ class LogoutPresenter( } } - fun handleEvent(event: LogoutEvents) { + fun handleEvent(event: LogoutEvent) { when (event) { - is LogoutEvents.Logout -> { + is LogoutEvent.Logout -> { if (logoutAction.value.isConfirming() || event.ignoreSdkError) { localCoroutineScope.logout(logoutAction, event.ignoreSdkError) } else { logoutAction.value = AsyncAction.ConfirmingNoParams } } - LogoutEvents.CloseDialogs -> { + LogoutEvent.CloseDialogs -> { logoutAction.value = AsyncAction.Uninitialized } } diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutState.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutState.kt index 9240edc61d..6233c1cb23 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutState.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutState.kt @@ -21,5 +21,5 @@ data class LogoutState( val backupUploadState: BackupUploadState, val waitingForALongTime: Boolean, val logoutAction: AsyncAction, - val eventSink: (LogoutEvents) -> Unit, + val eventSink: (LogoutEvent) -> Unit, ) diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutStatePreviewParam.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutStatePreviewParam.kt index 7bd55faa2c..e2d948a7f3 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutStatePreviewParam.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutStatePreviewParam.kt @@ -50,7 +50,7 @@ fun aLogoutState( backupUploadState: BackupUploadState = BackupUploadState.Unknown, waitingForALongTime: Boolean = false, logoutAction: AsyncAction = AsyncAction.Uninitialized, - eventSink: (LogoutEvents) -> Unit = {}, + eventSink: (LogoutEvent) -> Unit = {}, ) = LogoutState( isLastDevice = isLastDevice, backupState = backupState, diff --git a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutView.kt b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutView.kt index befabe7421..90a502fc16 100644 --- a/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutView.kt +++ b/features/logout/impl/src/main/kotlin/io/element/android/features/logout/impl/LogoutView.kt @@ -61,7 +61,7 @@ fun LogoutView( state = state, onChangeRecoveryKeyClick = onChangeRecoveryKeyClick, onLogoutClick = { - eventSink(LogoutEvents.Logout(ignoreSdkError = false)) + eventSink(LogoutEvent.Logout(ignoreSdkError = false)) } ) }, @@ -72,13 +72,13 @@ fun LogoutView( LogoutActionDialog( state.logoutAction, onConfirmClick = { - eventSink(LogoutEvents.Logout(ignoreSdkError = false)) + eventSink(LogoutEvent.Logout(ignoreSdkError = false)) }, onForceLogoutClick = { - eventSink(LogoutEvents.Logout(ignoreSdkError = true)) + eventSink(LogoutEvent.Logout(ignoreSdkError = true)) }, onDismissDialog = { - eventSink(LogoutEvents.CloseDialogs) + eventSink(LogoutEvent.CloseDialogs) }, ) } 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 274234a338..5b14bc5cc3 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 @@ -139,10 +139,10 @@ class LogoutPresenterTest { presenter.present() }.test { val initialState = awaitFirstItem() - initialState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) + initialState.eventSink.invoke(LogoutEvent.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) - initialState.eventSink.invoke(LogoutEvents.CloseDialogs) + initialState.eventSink.invoke(LogoutEvent.CloseDialogs) val finalState = awaitItem() assertThat(finalState.logoutAction).isEqualTo(AsyncAction.Uninitialized) } @@ -157,10 +157,10 @@ class LogoutPresenterTest { presenter.present() }.test { val initialState = awaitFirstItem() - initialState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) + initialState.eventSink.invoke(LogoutEvent.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) - confirmationState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) + confirmationState.eventSink.invoke(LogoutEvent.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) val successState = awaitItem() @@ -184,15 +184,15 @@ class LogoutPresenterTest { presenter.present() }.test { val initialState = awaitFirstItem() - initialState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) + initialState.eventSink.invoke(LogoutEvent.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) - confirmationState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) + confirmationState.eventSink.invoke(LogoutEvent.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) val errorState = awaitItem() assertThat(errorState.logoutAction).isEqualTo(AsyncAction.Failure(AN_EXCEPTION)) - errorState.eventSink.invoke(LogoutEvents.CloseDialogs) + errorState.eventSink.invoke(LogoutEvent.CloseDialogs) val finalState = awaitItem() assertThat(finalState.logoutAction).isEqualTo(AsyncAction.Uninitialized) } @@ -214,15 +214,15 @@ class LogoutPresenterTest { presenter.present() }.test { val initialState = awaitFirstItem() - initialState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) + initialState.eventSink.invoke(LogoutEvent.Logout(ignoreSdkError = false)) val confirmationState = awaitItem() assertThat(confirmationState.logoutAction).isEqualTo(AsyncAction.ConfirmingNoParams) - confirmationState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = false)) + confirmationState.eventSink.invoke(LogoutEvent.Logout(ignoreSdkError = false)) val loadingState = awaitItem() assertThat(loadingState.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) val errorState = awaitItem() assertThat(errorState.logoutAction).isEqualTo(AsyncAction.Failure(AN_EXCEPTION)) - errorState.eventSink.invoke(LogoutEvents.Logout(ignoreSdkError = true)) + errorState.eventSink.invoke(LogoutEvent.Logout(ignoreSdkError = true)) val loadingState2 = awaitItem() assertThat(loadingState2.logoutAction).isInstanceOf(AsyncAction.Loading::class.java) val successState = awaitItem() 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 3fbae4bbc5..f69ec8f0ca 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 @@ -28,20 +28,20 @@ import org.junit.Test class LogoutViewTest : RobolectricTest() { @Test - fun `clicking on logout sends a LogoutEvents`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + fun `clicking on logout sends a LogoutEvent`() = runAndroidComposeUiTest { + val eventsRecorder = EventsRecorder() setLogoutView( aLogoutState( eventSink = eventsRecorder ), ) clickOn(CommonStrings.action_signout) - eventsRecorder.assertSingle(LogoutEvents.Logout(false)) + eventsRecorder.assertSingle(LogoutEvent.Logout(false)) } @Test - fun `confirming logout sends a LogoutEvents`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + fun `confirming logout sends a LogoutEvent`() = runAndroidComposeUiTest { + val eventsRecorder = EventsRecorder() setLogoutView( aLogoutState( logoutAction = AsyncAction.ConfirmingNoParams, @@ -49,12 +49,12 @@ class LogoutViewTest : RobolectricTest() { ), ) pressTag(TestTags.dialogPositive.value) - eventsRecorder.assertSingle(LogoutEvents.Logout(false)) + eventsRecorder.assertSingle(LogoutEvent.Logout(false)) } @Test fun `clicking on back invoke back callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnce { callback -> setLogoutView( aLogoutState( @@ -67,8 +67,8 @@ class LogoutViewTest : RobolectricTest() { } @Test - fun `clicking on confirm after error sends a LogoutEvents`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + fun `clicking on confirm after error sends a LogoutEvent`() = runAndroidComposeUiTest { + val eventsRecorder = EventsRecorder() setLogoutView( aLogoutState( logoutAction = AsyncAction.Failure(Exception("Failed to logout")), @@ -76,12 +76,12 @@ class LogoutViewTest : RobolectricTest() { ), ) clickOn(CommonStrings.action_signout_anyway) - eventsRecorder.assertSingle(LogoutEvents.Logout(true)) + eventsRecorder.assertSingle(LogoutEvent.Logout(true)) } @Test - fun `clicking on cancel after error sends a LogoutEvents`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + fun `clicking on cancel after error sends a LogoutEvent`() = runAndroidComposeUiTest { + val eventsRecorder = EventsRecorder() setLogoutView( aLogoutState( logoutAction = AsyncAction.Failure(Exception("Failed to logout")), @@ -89,12 +89,12 @@ class LogoutViewTest : RobolectricTest() { ), ) clickOn(CommonStrings.action_cancel) - eventsRecorder.assertSingle(LogoutEvents.CloseDialogs) + eventsRecorder.assertSingle(LogoutEvent.CloseDialogs) } @Test fun `last session setting button invoke onChangeRecoveryKeyClicked`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnce { callback -> setLogoutView( aLogoutState(