From 87af3b85b3d897c7f509cb771a9dad262df69e94 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 25 Aug 2026 10:06:58 +0200 Subject: [PATCH] `PollHistoryEvents` -> `PollHistoryEvent` --- ...llHistoryEvents.kt => PollHistoryEvent.kt} | 10 +++++----- .../poll/impl/history/PollHistoryPresenter.kt | 10 +++++----- .../poll/impl/history/PollHistoryState.kt | 2 +- .../history/PollHistoryStatePreviewParam.kt | 2 +- .../poll/impl/history/PollHistoryView.kt | 8 ++++---- .../impl/history/PollHistoryPresenterTest.kt | 10 +++++----- .../poll/impl/history/PollHistoryViewTest.kt | 20 +++++++++---------- 7 files changed, 31 insertions(+), 31 deletions(-) rename features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/{PollHistoryEvents.kt => PollHistoryEvent.kt} (81%) diff --git a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryEvents.kt b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryEvent.kt similarity index 81% rename from features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryEvents.kt rename to features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryEvent.kt index 14ce13d67a..9d0d699d89 100644 --- a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryEvents.kt +++ b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryEvent.kt @@ -11,9 +11,9 @@ package io.element.android.features.poll.impl.history import io.element.android.features.poll.impl.history.model.PollHistoryFilter import io.element.android.libraries.matrix.api.core.EventId -sealed interface PollHistoryEvents { - data object LoadMore : PollHistoryEvents - data class SelectPollAnswer(val pollStartId: EventId, val answerId: String) : PollHistoryEvents - data class EndPoll(val pollStartId: EventId) : PollHistoryEvents - data class SelectFilter(val filter: PollHistoryFilter) : PollHistoryEvents +sealed interface PollHistoryEvent { + data object LoadMore : PollHistoryEvent + data class SelectPollAnswer(val pollStartId: EventId, val answerId: String) : PollHistoryEvent + data class EndPoll(val pollStartId: EventId) : PollHistoryEvent + data class SelectFilter(val filter: PollHistoryFilter) : PollHistoryEvent } diff --git a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenter.kt b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenter.kt index 434e2ed18c..74a511da45 100644 --- a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenter.kt +++ b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenter.kt @@ -63,22 +63,22 @@ class PollHistoryPresenter( } } val coroutineScope = rememberCoroutineScope() - fun handleEvent(event: PollHistoryEvents) { + fun handleEvent(event: PollHistoryEvent) { when (event) { - is PollHistoryEvents.LoadMore -> { + is PollHistoryEvent.LoadMore -> { coroutineScope.loadMore(timeline) } - is PollHistoryEvents.SelectPollAnswer -> sessionCoroutineScope.launch { + is PollHistoryEvent.SelectPollAnswer -> sessionCoroutineScope.launch { sendPollResponseAction.execute( timeline = timeline, pollStartId = event.pollStartId, answerId = event.answerId ) } - is PollHistoryEvents.EndPoll -> sessionCoroutineScope.launch { + is PollHistoryEvent.EndPoll -> sessionCoroutineScope.launch { endPollAction.execute(timeline = timeline, pollStartId = event.pollStartId) } - is PollHistoryEvents.SelectFilter -> { + is PollHistoryEvent.SelectFilter -> { activeFilter = event.filter } } diff --git a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryState.kt b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryState.kt index bddfd153f6..67225e85c2 100644 --- a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryState.kt +++ b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryState.kt @@ -18,7 +18,7 @@ data class PollHistoryState( val hasMoreToLoad: Boolean, val activeFilter: PollHistoryFilter, val pollHistoryItems: PollHistoryItems, - val eventSink: (PollHistoryEvents) -> Unit, + val eventSink: (PollHistoryEvent) -> Unit, ) { fun pollHistoryForFilter(filter: PollHistoryFilter): ImmutableList { return when (filter) { diff --git a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryStatePreviewParam.kt b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryStatePreviewParam.kt index ff07eaee37..40144f261e 100644 --- a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryStatePreviewParam.kt +++ b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryStatePreviewParam.kt @@ -48,7 +48,7 @@ internal fun aPollHistoryState( currentItems: List = listOf( aPollHistoryItem(), ), - eventSink: (PollHistoryEvents) -> Unit = {}, + eventSink: (PollHistoryEvent) -> Unit = {}, ) = PollHistoryState( isLoading = isLoading, hasMoreToLoad = hasMoreToLoad, diff --git a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt index 01b475593d..61c7809f49 100644 --- a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt +++ b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt @@ -62,15 +62,15 @@ fun PollHistoryView( modifier: Modifier = Modifier, ) { fun onLoadMore() { - state.eventSink(PollHistoryEvents.LoadMore) + state.eventSink(PollHistoryEvent.LoadMore) } fun onSelectAnswer(pollStartId: EventId, answerId: String) { - state.eventSink(PollHistoryEvents.SelectPollAnswer(pollStartId, answerId)) + state.eventSink(PollHistoryEvent.SelectPollAnswer(pollStartId, answerId)) } fun onEndPoll(pollStartId: EventId) { - state.eventSink(PollHistoryEvents.EndPoll(pollStartId)) + state.eventSink(PollHistoryEvent.EndPoll(pollStartId)) } Scaffold( @@ -97,7 +97,7 @@ fun PollHistoryView( } PollHistoryFilterButtons( activeFilter = state.activeFilter, - onSelectFilter = { state.eventSink(PollHistoryEvents.SelectFilter(it)) }, + onSelectFilter = { state.eventSink(PollHistoryEvent.SelectFilter(it)) }, modifier = Modifier .fillMaxWidth() .padding(horizontal = 16.dp, vertical = 8.dp), diff --git a/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt b/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt index 8d4cedc6a8..1342f89c60 100644 --- a/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt +++ b/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt @@ -88,12 +88,12 @@ class PollHistoryPresenterTest { }.test { awaitItem().also { state -> assertThat(state.activeFilter).isEqualTo(PollHistoryFilter.ONGOING) - state.eventSink(PollHistoryEvents.SelectFilter(PollHistoryFilter.PAST)) + state.eventSink(PollHistoryEvent.SelectFilter(PollHistoryFilter.PAST)) } skipItems(1) awaitItem().also { state -> assertThat(state.activeFilter).isEqualTo(PollHistoryFilter.PAST) - state.eventSink(PollHistoryEvents.SelectFilter(PollHistoryFilter.ONGOING)) + state.eventSink(PollHistoryEvent.SelectFilter(PollHistoryFilter.ONGOING)) } awaitItem().also { state -> assertThat(state.activeFilter).isEqualTo(PollHistoryFilter.ONGOING) @@ -114,10 +114,10 @@ class PollHistoryPresenterTest { presenter.present() }.test { val state = awaitItem() - state.eventSink(PollHistoryEvents.EndPoll(AN_EVENT_ID)) + state.eventSink(PollHistoryEvent.EndPoll(AN_EVENT_ID)) runCurrent() endPollAction.verifyExecutionCount(1) - state.eventSink(PollHistoryEvents.SelectPollAnswer(AN_EVENT_ID, "answer")) + state.eventSink(PollHistoryEvent.SelectPollAnswer(AN_EVENT_ID, "answer")) runCurrent() sendPollResponseAction.verifyExecutionCount(1) cancelAndConsumeRemainingEvents() @@ -139,7 +139,7 @@ class PollHistoryPresenterTest { skipItems(1) val loadedState = awaitItem() assertThat(loadedState.isLoading).isFalse() - loadedState.eventSink(PollHistoryEvents.LoadMore) + loadedState.eventSink(PollHistoryEvent.LoadMore) backwardPaginationStatus.getAndUpdate { it.copy(isPaginating = true) } awaitItem().also { state -> assertThat(state.isLoading).isTrue() diff --git a/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt b/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt index ee6ad69ba6..1b74118734 100644 --- a/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt +++ b/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt @@ -35,7 +35,7 @@ import org.robolectric.annotation.Config class PollHistoryViewTest : RobolectricTest() { @Test fun `clicking on back invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) ensureCalledOnce { setPollHistoryViewView( aPollHistoryState( @@ -50,7 +50,7 @@ class PollHistoryViewTest : RobolectricTest() { @Config(qualifiers = "h1024dp") @Test fun `clicking on edit poll invokes the expected callback`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder(expectEvents = false) + val eventsRecorder = EventsRecorder(expectEvents = false) val eventId = EventId("\$anEventId") val state = aPollHistoryState( currentItems = listOf( @@ -76,7 +76,7 @@ class PollHistoryViewTest : RobolectricTest() { @Config(qualifiers = "h1024dp") @Test fun `clicking on poll end emits the expected Event`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() val eventId = EventId("\$anEventId") val state = aPollHistoryState( currentItems = listOf( @@ -102,14 +102,14 @@ class PollHistoryViewTest : RobolectricTest() { eventsRecorder.assertEmpty() clickOn(CommonStrings.action_ok) eventsRecorder.assertSingle( - PollHistoryEvents.EndPoll(eventId) + PollHistoryEvent.EndPoll(eventId) ) } @Config(qualifiers = "h1024dp") @Test fun `clicking on poll answer emits the expected Event`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() val eventId = EventId("\$anEventId") val state = aPollHistoryState( currentItems = listOf( @@ -133,13 +133,13 @@ class PollHistoryViewTest : RobolectricTest() { useUnmergedTree = true, ).performClick() eventsRecorder.assertSingle( - PollHistoryEvents.SelectPollAnswer(eventId, answer.id) + PollHistoryEvent.SelectPollAnswer(eventId, answer.id) ) } @Test fun `clicking on past tab emits the expected Event`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setPollHistoryViewView( aPollHistoryState( eventSink = eventsRecorder @@ -147,14 +147,14 @@ class PollHistoryViewTest : RobolectricTest() { ) clickOn(R.string.screen_polls_history_filter_past) eventsRecorder.assertSingle( - PollHistoryEvents.SelectFilter(filter = PollHistoryFilter.PAST) + PollHistoryEvent.SelectFilter(filter = PollHistoryFilter.PAST) ) } @Config(qualifiers = "h1024dp") @Test fun `clicking on load more emits the expected Event`() = runAndroidComposeUiTest { - val eventsRecorder = EventsRecorder() + val eventsRecorder = EventsRecorder() setPollHistoryViewView( aPollHistoryState( hasMoreToLoad = true, @@ -163,7 +163,7 @@ class PollHistoryViewTest : RobolectricTest() { ) clickOn(CommonStrings.action_load_more) eventsRecorder.assertSingle( - PollHistoryEvents.LoadMore + PollHistoryEvent.LoadMore ) } }