Skip to content

Commit

Permalink
Renaming of filter enum
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaturel committed Jan 5, 2023
1 parent 354554e commit d604035
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package im.vector.app.features.roomprofile.polls

enum class RoomPollsFilter {
enum class RoomPollsFilterType {
ACTIVE,
ENDED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d604035

Please sign in to comment.