Browse Source

Rename Event of PollHistoryEvents

pull/2936/head
Benoit Marty 4 months ago
parent
commit
7eb7e21d27
  1. 6
      features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryEvents.kt
  2. 6
      features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenter.kt
  3. 6
      features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt
  4. 8
      features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt
  5. 6
      features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt

6
features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryEvents.kt

@ -21,7 +21,7 @@ import io.element.android.libraries.matrix.api.core.EventId @@ -21,7 +21,7 @@ import io.element.android.libraries.matrix.api.core.EventId
sealed interface PollHistoryEvents {
data object LoadMore : PollHistoryEvents
data class PollAnswerSelected(val pollStartId: EventId, val answerId: String) : PollHistoryEvents
data class PollEndClicked(val pollStartId: EventId) : PollHistoryEvents
data class OnFilterSelected(val filter: PollHistoryFilter) : 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
}

6
features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenter.kt

@ -73,13 +73,13 @@ class PollHistoryPresenter @Inject constructor( @@ -73,13 +73,13 @@ class PollHistoryPresenter @Inject constructor(
is PollHistoryEvents.LoadMore -> {
coroutineScope.loadMore(timeline)
}
is PollHistoryEvents.PollAnswerSelected -> appCoroutineScope.launch {
is PollHistoryEvents.SelectPollAnswer -> appCoroutineScope.launch {
sendPollResponseAction.execute(pollStartId = event.pollStartId, answerId = event.answerId)
}
is PollHistoryEvents.PollEndClicked -> appCoroutineScope.launch {
is PollHistoryEvents.EndPoll -> appCoroutineScope.launch {
endPollAction.execute(pollStartId = event.pollStartId)
}
is PollHistoryEvents.OnFilterSelected -> {
is PollHistoryEvents.SelectFilter -> {
activeFilter = event.filter
}
}

6
features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt

@ -75,11 +75,11 @@ fun PollHistoryView( @@ -75,11 +75,11 @@ fun PollHistoryView(
}
fun onSelectAnswer(pollStartId: EventId, answerId: String) {
state.eventSink(PollHistoryEvents.PollAnswerSelected(pollStartId, answerId))
state.eventSink(PollHistoryEvents.SelectPollAnswer(pollStartId, answerId))
}
fun onEndPoll(pollStartId: EventId) {
state.eventSink(PollHistoryEvents.PollEndClicked(pollStartId))
state.eventSink(PollHistoryEvents.EndPoll(pollStartId))
}
Scaffold(
@ -111,7 +111,7 @@ fun PollHistoryView( @@ -111,7 +111,7 @@ fun PollHistoryView(
}
PollHistoryFilterButtons(
activeFilter = state.activeFilter,
onSelectFilter = { state.eventSink(PollHistoryEvents.OnFilterSelected(it)) },
onSelectFilter = { state.eventSink(PollHistoryEvents.SelectFilter(it)) },
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),

8
features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt

@ -99,12 +99,12 @@ class PollHistoryPresenterTest { @@ -99,12 +99,12 @@ class PollHistoryPresenterTest {
}.test {
awaitItem().also { state ->
assertThat(state.activeFilter).isEqualTo(PollHistoryFilter.ONGOING)
state.eventSink(PollHistoryEvents.OnFilterSelected(PollHistoryFilter.PAST))
state.eventSink(PollHistoryEvents.SelectFilter(PollHistoryFilter.PAST))
}
skipItems(1)
awaitItem().also { state ->
assertThat(state.activeFilter).isEqualTo(PollHistoryFilter.PAST)
state.eventSink(PollHistoryEvents.OnFilterSelected(PollHistoryFilter.ONGOING))
state.eventSink(PollHistoryEvents.SelectFilter(PollHistoryFilter.ONGOING))
}
awaitItem().also { state ->
assertThat(state.activeFilter).isEqualTo(PollHistoryFilter.ONGOING)
@ -125,10 +125,10 @@ class PollHistoryPresenterTest { @@ -125,10 +125,10 @@ class PollHistoryPresenterTest {
presenter.present()
}.test {
val state = awaitItem()
state.eventSink(PollHistoryEvents.PollEndClicked(AN_EVENT_ID))
state.eventSink(PollHistoryEvents.EndPoll(AN_EVENT_ID))
runCurrent()
endPollAction.verifyExecutionCount(1)
state.eventSink(PollHistoryEvents.PollAnswerSelected(AN_EVENT_ID, "answer"))
state.eventSink(PollHistoryEvents.SelectPollAnswer(AN_EVENT_ID, "answer"))
runCurrent()
sendPollResponseAction.verifyExecutionCount(1)
cancelAndConsumeRemainingEvents()

6
features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryViewTest.kt

@ -114,7 +114,7 @@ class PollHistoryViewTest { @@ -114,7 +114,7 @@ class PollHistoryViewTest {
eventsRecorder.assertEmpty()
rule.clickOn(CommonStrings.action_ok)
eventsRecorder.assertSingle(
PollHistoryEvents.PollEndClicked(eventId)
PollHistoryEvents.EndPoll(eventId)
)
}
@ -142,7 +142,7 @@ class PollHistoryViewTest { @@ -142,7 +142,7 @@ class PollHistoryViewTest {
)
rule.onNodeWithText(answer.text).performClick()
eventsRecorder.assertSingle(
PollHistoryEvents.PollAnswerSelected(eventId, answer.id)
PollHistoryEvents.SelectPollAnswer(eventId, answer.id)
)
}
@ -156,7 +156,7 @@ class PollHistoryViewTest { @@ -156,7 +156,7 @@ class PollHistoryViewTest {
)
rule.clickOn(R.string.screen_polls_history_filter_past)
eventsRecorder.assertSingle(
PollHistoryEvents.OnFilterSelected(filter = PollHistoryFilter.PAST)
PollHistoryEvents.SelectFilter(filter = PollHistoryFilter.PAST)
)
}

Loading…
Cancel
Save