Renaming of filter enum

This commit is contained in:
Maxime NATUREL 2023-01-05 15:09:41 +01:00
parent 354554e843
commit d60403545c
6 changed files with 9 additions and 9 deletions

View file

@ -24,11 +24,11 @@ import javax.inject.Inject
class GetPollsUseCase @Inject constructor() {
fun execute(filter: RoomPollsFilter): Flow<List<PollSummary>> {
fun execute(filter: RoomPollsFilterType): Flow<List<PollSummary>> {
// TODO unmock and add unit tests
return when (filter) {
RoomPollsFilter.ACTIVE -> getActivePolls()
RoomPollsFilter.ENDED -> emptyFlow()
RoomPollsFilterType.ACTIVE -> getActivePolls()
RoomPollsFilterType.ENDED -> emptyFlow()
}.map { it.sortedByDescending { poll -> poll.creationTimestamp } }
}

View file

@ -19,5 +19,5 @@ package im.vector.app.features.roomprofile.polls
import im.vector.app.core.platform.VectorViewModelAction
sealed interface RoomPollsAction : VectorViewModelAction {
data class SetFilter(val filter: RoomPollsFilter) : RoomPollsAction
data class SetFilter(val filter: RoomPollsFilterType) : RoomPollsAction
}

View file

@ -16,7 +16,7 @@
package im.vector.app.features.roomprofile.polls
enum class RoomPollsFilter {
enum class RoomPollsFilterType {
ACTIVE,
ENDED,
}

View file

@ -54,7 +54,7 @@ class RoomPollsViewModel @AssistedInject constructor(
super.onCleared()
}
private fun handleSetFilter(filter: RoomPollsFilter) {
private fun handleSetFilter(filter: RoomPollsFilterType) {
pollsCollectionJob?.cancel()
pollsCollectionJob = getPollsUseCase.execute(filter)
.onEach { setState { copy(polls = it) } }

View file

@ -31,7 +31,7 @@ import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentRoomPollsListBinding
import im.vector.app.features.roomprofile.polls.PollSummary
import im.vector.app.features.roomprofile.polls.RoomPollsAction
import im.vector.app.features.roomprofile.polls.RoomPollsFilter
import im.vector.app.features.roomprofile.polls.RoomPollsFilterType
import im.vector.app.features.roomprofile.polls.RoomPollsViewModel
import timber.log.Timber
import javax.inject.Inject
@ -73,7 +73,7 @@ class RoomActivePollsFragment :
override fun onResume() {
super.onResume()
viewModel.handle(RoomPollsAction.SetFilter(RoomPollsFilter.ACTIVE))
viewModel.handle(RoomPollsAction.SetFilter(RoomPollsFilterType.ACTIVE))
}
override fun invalidate() = withState(viewModel) { viewState ->

View file

@ -47,7 +47,7 @@ class RoomPollsViewModelTest {
@Test
fun `given SetFilter action when handle then useCase is called with given filter and viewState is updated`() {
// Given
val filter = RoomPollsFilter.ACTIVE
val filter = RoomPollsFilterType.ACTIVE
val action = RoomPollsAction.SetFilter(filter = filter)
val polls = listOf(givenAPollSummary())
every { fakeGetPollsUseCase.execute(any()) } returns flowOf(polls)