From cf7d5ab4b46286821dde804b156fbbb68df1fa24 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 25 Aug 2026 10:27:26 +0200 Subject: [PATCH] `StartChatEvents` -> `StartChatEvent` --- .../root/{StartChatEvents.kt => StartChatEvent.kt} | 6 +++--- .../startchat/impl/root/StartChatPresenter.kt | 6 +++--- .../features/startchat/impl/root/StartChatState.kt | 2 +- .../impl/root/StartChatStatePreviewParam.kt | 2 +- .../features/startchat/impl/root/StartChatView.kt | 12 ++++++------ .../startchat/impl/root/StartChatPresenterTest.kt | 14 +++++++------- .../startchat/impl/root/StartChatViewTest.kt | 12 ++++++------ 7 files changed, 27 insertions(+), 27 deletions(-) rename features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/{StartChatEvents.kt => StartChatEvent.kt} (82%) diff --git a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatEvents.kt b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatEvent.kt similarity index 82% rename from features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatEvents.kt rename to features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatEvent.kt index 66e135b45c..68f50c41ee 100644 --- a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatEvents.kt +++ b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatEvent.kt @@ -10,7 +10,7 @@ package io.element.android.features.startchat.impl.root import io.element.android.libraries.matrix.api.user.MatrixUser -sealed interface StartChatEvents { - data class StartDM(val matrixUser: MatrixUser) : StartChatEvents - data object CancelStartDM : StartChatEvents +sealed interface StartChatEvent { + data class StartDM(val matrixUser: MatrixUser) : StartChatEvent + data object CancelStartDM : StartChatEvent } diff --git a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenter.kt b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenter.kt index 079ece4180..8b1f92222e 100644 --- a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenter.kt +++ b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenter.kt @@ -49,16 +49,16 @@ class StartChatPresenter( val localCoroutineScope = rememberCoroutineScope() val startDmActionState: MutableState> = remember { mutableStateOf(AsyncAction.Uninitialized) } - fun handleEvent(event: StartChatEvents) { + fun handleEvent(event: StartChatEvent) { when (event) { - is StartChatEvents.StartDM -> localCoroutineScope.launch { + is StartChatEvent.StartDM -> localCoroutineScope.launch { startDMAction.execute( matrixUser = event.matrixUser, createIfDmDoesNotExist = startDmActionState.value is AsyncAction.Confirming, actionState = startDmActionState, ) } - StartChatEvents.CancelStartDM -> startDmActionState.value = AsyncAction.Uninitialized + StartChatEvent.CancelStartDM -> startDmActionState.value = AsyncAction.Uninitialized } } diff --git a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatState.kt b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatState.kt index e6746e1302..167e4f444a 100644 --- a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatState.kt +++ b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatState.kt @@ -16,5 +16,5 @@ data class StartChatState( val applicationName: String, val userListState: UserListState, val startDmAction: AsyncAction, - val eventSink: (StartChatEvents) -> Unit, + val eventSink: (StartChatEvent) -> Unit, ) diff --git a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatStatePreviewParam.kt b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatStatePreviewParam.kt index e8ac1d55a7..bd7c24da41 100644 --- a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatStatePreviewParam.kt +++ b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatStatePreviewParam.kt @@ -72,7 +72,7 @@ fun aCreateRoomRootState( applicationName: String = "Element X Preview", userListState: UserListState = aUserListState(), startDmAction: AsyncAction = AsyncAction.Uninitialized, - eventSink: (StartChatEvents) -> Unit = {}, + eventSink: (StartChatEvent) -> Unit = {}, ) = StartChatState( applicationName = applicationName, userListState = userListState, diff --git a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatView.kt b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatView.kt index 350cf15757..3ef807b777 100644 --- a/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatView.kt +++ b/features/startchat/impl/src/main/kotlin/io/element/android/features/startchat/impl/root/StartChatView.kt @@ -94,7 +94,7 @@ fun StartChatView( onSelectUser = { coroutineScope.launch { view.hideKeyboardAndAwaitAnimation() - state.eventSink(StartChatEvents.StartDM(it)) + state.eventSink(StartChatEvent.StartDM(it)) } }, onDeselectUser = { }, @@ -124,21 +124,21 @@ fun StartChatView( errorMessage = { stringResource(R.string.screen_start_chat_error_starting_chat) }, onRetry = { state.userListState.selectedUsers.firstOrNull() - ?.let { state.eventSink(StartChatEvents.StartDM(it)) } + ?.let { state.eventSink(StartChatEvent.StartDM(it)) } // Cancel start DM if there is no more selected user (should not happen) - ?: state.eventSink(StartChatEvents.CancelStartDM) + ?: state.eventSink(StartChatEvent.CancelStartDM) }, - onErrorDismiss = { state.eventSink(StartChatEvents.CancelStartDM) }, + onErrorDismiss = { state.eventSink(StartChatEvent.CancelStartDM) }, confirmationDialog = { data -> if (data is ConfirmingStartDmWithMatrixUser) { CreateDmConfirmationBottomSheet( matrixUser = data.matrixUser, isUserIdentityUnknown = data.isUserIdentityUnknown, onSendInvite = { - state.eventSink(StartChatEvents.StartDM(data.matrixUser)) + state.eventSink(StartChatEvent.StartDM(data.matrixUser)) }, onDismiss = { - state.eventSink(StartChatEvents.CancelStartDM) + state.eventSink(StartChatEvent.CancelStartDM) }, ) } diff --git a/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenterTest.kt b/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenterTest.kt index 57f6cd2333..39d6f34b21 100644 --- a/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenterTest.kt +++ b/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenterTest.kt @@ -53,7 +53,7 @@ class StartChatPresenterTest { assertThat(initialState.userListState.isSearchActive).isFalse() assertThat(initialState.userListState.isMultiSelectionEnabled).isFalse() val matrixUser = MatrixUser(UserId("@name:domain")) - initialState.eventSink(StartChatEvents.StartDM(matrixUser)) + initialState.eventSink(StartChatEvent.StartDM(matrixUser)) awaitItem().also { state -> assertThat(state.startDmAction).isEqualTo(startDMFailureResult) executeResult.assertions().isCalledOnce().with( @@ -61,7 +61,7 @@ class StartChatPresenterTest { value(false), any(), ) - state.eventSink(StartChatEvents.CancelStartDM) + state.eventSink(StartChatEvent.CancelStartDM) } awaitItem().also { state -> assertThat(state.startDmAction.isUninitialized()).isTrue() @@ -85,7 +85,7 @@ class StartChatPresenterTest { assertThat(initialState.userListState.isSearchActive).isFalse() assertThat(initialState.userListState.isMultiSelectionEnabled).isFalse() val matrixUser = MatrixUser(UserId("@name:domain")) - initialState.eventSink(StartChatEvents.StartDM(matrixUser)) + initialState.eventSink(StartChatEvent.StartDM(matrixUser)) awaitItem().also { state -> assertThat(state.startDmAction).isEqualTo(startDMSuccessResult) executeResult.assertions().isCalledOnce().with( @@ -109,7 +109,7 @@ class StartChatPresenterTest { presenter.test { val initialState = awaitItem() assertThat(initialState.startDmAction).isInstanceOf(AsyncAction.Uninitialized::class.java) - initialState.eventSink(StartChatEvents.StartDM(matrixUser)) + initialState.eventSink(StartChatEvent.StartDM(matrixUser)) val confirmingState = awaitItem() assertThat(confirmingState.startDmAction).isEqualTo(startDMConfirmationResult) executeResult.assertions().isCalledOnce().with( @@ -118,7 +118,7 @@ class StartChatPresenterTest { any(), ) // Cancelling should not create the DM - confirmingState.eventSink(StartChatEvents.CancelStartDM) + confirmingState.eventSink(StartChatEvent.CancelStartDM) val finalState = awaitItem() assertThat(finalState.startDmAction.isUninitialized()).isTrue() executeResult.assertions().isCalledExactly(1) @@ -137,7 +137,7 @@ class StartChatPresenterTest { presenter.test { val initialState = awaitItem() assertThat(initialState.startDmAction).isInstanceOf(AsyncAction.Uninitialized::class.java) - initialState.eventSink(StartChatEvents.StartDM(matrixUser)) + initialState.eventSink(StartChatEvent.StartDM(matrixUser)) val confirmingState = awaitItem() assertThat(confirmingState.startDmAction).isEqualTo(startDMConfirmationResult) executeResult.assertions().isCalledOnce().with( @@ -146,7 +146,7 @@ class StartChatPresenterTest { any(), ) // Start DM again should invoke the action with createIfDmDoesNotExist = true - confirmingState.eventSink(StartChatEvents.StartDM(matrixUser)) + confirmingState.eventSink(StartChatEvent.StartDM(matrixUser)) executeResult.assertions().isCalledExactly(2).withSequence( listOf(value(matrixUser), value(false), any()), listOf(value(matrixUser), value(true), any()), diff --git a/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatViewTest.kt b/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatViewTest.kt index 8b5e1da8e6..7b7c046bb2 100644 --- a/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatViewTest.kt +++ b/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatViewTest.kt @@ -36,7 +36,7 @@ import org.robolectric.annotation.Config class StartChatViewTest : RobolectricTest() { @Test fun `clicking on back invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnce { setStartChatView( aCreateRoomRootState( @@ -50,7 +50,7 @@ class StartChatViewTest : RobolectricTest() { @Test fun `clicking on New room invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnce { setStartChatView( aCreateRoomRootState( @@ -65,7 +65,7 @@ class StartChatViewTest : RobolectricTest() { @Config(qualifiers = "h1024dp") @Test fun `clicking on Invite people invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnce { setStartChatView( aCreateRoomRootState( @@ -84,7 +84,7 @@ class StartChatViewTest : RobolectricTest() { fun `clicking on a user suggestion invokes the expected callback`() = runAndroidComposeUiTest { val recentDirectRoomList = aRecentDirectRoomList() val firstRoom = recentDirectRoomList[0] - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnceWithParam(firstRoom.roomId) { setStartChatView( aCreateRoomRootState( @@ -102,7 +102,7 @@ class StartChatViewTest : RobolectricTest() { @Config(qualifiers = "h1024dp") @Test fun `clicking on Join room by address invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnce { setStartChatView( aCreateRoomRootState( @@ -116,7 +116,7 @@ class StartChatViewTest : RobolectricTest() { @Test fun `clicking on room directory invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnce { setStartChatView( aCreateRoomRootState(