mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-28 22:18:46 +03:00
Renaming of filter enum
This commit is contained in:
parent
354554e843
commit
d60403545c
6 changed files with 9 additions and 9 deletions
|
@ -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 } }
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package im.vector.app.features.roomprofile.polls
|
||||
|
||||
enum class RoomPollsFilter {
|
||||
enum class RoomPollsFilterType {
|
||||
ACTIVE,
|
||||
ENDED,
|
||||
}
|
|
@ -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) } }
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue