From c92d34f46a88641d0b94d5d884fb39d7fb269a02 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 27 Jan 2026 15:01:26 +0100 Subject: [PATCH] HomeEvents -> HomeEvent --- .../features/home/impl/{HomeEvents.kt => HomeEvent.kt} | 6 +++--- .../io/element/android/features/home/impl/HomePresenter.kt | 6 +++--- .../io/element/android/features/home/impl/HomeState.kt | 2 +- .../element/android/features/home/impl/HomeStateProvider.kt | 2 +- .../io/element/android/features/home/impl/HomeView.kt | 6 +++--- .../element/android/features/home/impl/HomePresenterTest.kt | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) rename features/home/impl/src/main/kotlin/io/element/android/features/home/impl/{HomeEvents.kt => HomeEvent.kt} (88%) diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeEvents.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeEvent.kt similarity index 88% rename from features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeEvents.kt rename to features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeEvent.kt index db9dafba63..7d2bb09d30 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeEvents.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeEvent.kt @@ -10,7 +10,7 @@ package io.element.android.features.home.impl import io.element.android.libraries.matrix.api.core.SessionId -sealed interface HomeEvents { - data class SelectHomeNavigationBarItem(val item: HomeNavigationBarItem) : HomeEvents - data class SwitchToAccount(val sessionId: SessionId) : HomeEvents +sealed interface HomeEvent { + data class SelectHomeNavigationBarItem(val item: HomeNavigationBarItem) : HomeEvent + data class SwitchToAccount(val sessionId: SessionId) : HomeEvent } diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomePresenter.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomePresenter.kt index e03b40e840..6878f4d53c 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomePresenter.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomePresenter.kt @@ -80,15 +80,15 @@ class HomePresenter( val showAvatarIndicator by indicatorService.showRoomListTopBarIndicator() val directLogoutState = logoutPresenter.present() - fun handleEvent(event: HomeEvents) { + fun handleEvent(event: HomeEvent) { when (event) { - is HomeEvents.SelectHomeNavigationBarItem -> coroutineState.launch { + is HomeEvent.SelectHomeNavigationBarItem -> coroutineState.launch { if (event.item == HomeNavigationBarItem.Spaces) { announcementService.showAnnouncement(Announcement.Space) } currentHomeNavigationBarItemOrdinal = event.item.ordinal } - is HomeEvents.SwitchToAccount -> coroutineState.launch { + is HomeEvent.SwitchToAccount -> coroutineState.launch { sessionStore.setLatestSession(event.sessionId.value) } } diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeState.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeState.kt index 1850d2d4cc..07b4be123c 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeState.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeState.kt @@ -29,7 +29,7 @@ data class HomeState( val snackbarMessage: SnackbarMessage?, val canReportBug: Boolean, val directLogoutState: DirectLogoutState, - val eventSink: (HomeEvents) -> Unit, + val eventSink: (HomeEvent) -> Unit, ) { val displayActions = currentHomeNavigationBarItem == HomeNavigationBarItem.Chats val displayRoomListFilters = currentHomeNavigationBarItem == HomeNavigationBarItem.Chats && roomListState.displayFilters diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeStateProvider.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeStateProvider.kt index e68ff7aa1f..2c4c76fabe 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeStateProvider.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeStateProvider.kt @@ -59,7 +59,7 @@ internal fun aHomeState( homeSpacesState: HomeSpacesState = aHomeSpacesState(), canReportBug: Boolean = true, directLogoutState: DirectLogoutState = aDirectLogoutState(), - eventSink: (HomeEvents) -> Unit = {} + eventSink: (HomeEvent) -> Unit = {} ) = HomeState( currentUserAndNeighbors = currentUserAndNeighbors.toImmutableList(), showAvatarIndicator = showAvatarIndicator, diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeView.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeView.kt index 52745108f6..83efc39f82 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeView.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/HomeView.kt @@ -156,7 +156,7 @@ private fun HomeScaffold( BackHandler( enabled = state.currentHomeNavigationBarItem != HomeNavigationBarItem.Chats, ) { - state.eventSink(HomeEvents.SelectHomeNavigationBarItem(HomeNavigationBarItem.Chats)) + state.eventSink(HomeEvent.SelectHomeNavigationBarItem(HomeNavigationBarItem.Chats)) } val hazeState = rememberHazeState() @@ -176,7 +176,7 @@ private fun HomeScaffold( onMenuActionClick = onMenuActionClick, onOpenSettings = onOpenSettings, onAccountSwitch = { - state.eventSink(HomeEvents.SwitchToAccount(it)) + state.eventSink(HomeEvent.SwitchToAccount(it)) }, onCreateSpace = onCreateSpaceClick, scrollBehavior = scrollBehavior, @@ -211,7 +211,7 @@ private fun HomeScaffold( lazyListStateTarget.animateScrollToItem(0) } } else { - state.eventSink(HomeEvents.SelectHomeNavigationBarItem(item)) + state.eventSink(HomeEvent.SelectHomeNavigationBarItem(item)) } }, modifier = Modifier.hazeEffect( diff --git a/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/HomePresenterTest.kt b/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/HomePresenterTest.kt index 37ed6e6909..bcae28c041 100644 --- a/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/HomePresenterTest.kt +++ b/features/home/impl/src/test/kotlin/io/element/android/features/home/impl/HomePresenterTest.kt @@ -164,7 +164,7 @@ class HomePresenterTest { }.test { val initialState = awaitItem() assertThat(initialState.currentHomeNavigationBarItem).isEqualTo(HomeNavigationBarItem.Chats) - initialState.eventSink(HomeEvents.SelectHomeNavigationBarItem(HomeNavigationBarItem.Spaces)) + initialState.eventSink(HomeEvent.SelectHomeNavigationBarItem(HomeNavigationBarItem.Spaces)) val finalState = awaitItem() assertThat(finalState.currentHomeNavigationBarItem).isEqualTo(HomeNavigationBarItem.Spaces) showAnnouncementResult.assertions().isCalledOnce() @@ -189,7 +189,7 @@ class HomePresenterTest { assertThat(initialState.currentHomeNavigationBarItem).isEqualTo(HomeNavigationBarItem.Chats) assertThat(initialState.showNavigationBar).isTrue() // User navigate to Spaces - initialState.eventSink(HomeEvents.SelectHomeNavigationBarItem(HomeNavigationBarItem.Spaces)) + initialState.eventSink(HomeEvent.SelectHomeNavigationBarItem(HomeNavigationBarItem.Spaces)) val spaceState = awaitItem() assertThat(spaceState.currentHomeNavigationBarItem).isEqualTo(HomeNavigationBarItem.Spaces) // The last space is left