mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
PollHistoryEvents -> PollHistoryEvent
This commit is contained in:
+5
-5
@@ -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
|
||||
}
|
||||
+5
-5
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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<PollHistoryItem> {
|
||||
return when (filter) {
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ internal fun aPollHistoryState(
|
||||
currentItems: List<PollHistoryItem> = listOf(
|
||||
aPollHistoryItem(),
|
||||
),
|
||||
eventSink: (PollHistoryEvents) -> Unit = {},
|
||||
eventSink: (PollHistoryEvent) -> Unit = {},
|
||||
) = PollHistoryState(
|
||||
isLoading = isLoading,
|
||||
hasMoreToLoad = hasMoreToLoad,
|
||||
|
||||
+4
-4
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user