Adding mocked data for ended polls

This commit is contained in:
Maxime NATUREL 2022-12-30 17:38:55 +01:00
parent 740591cd38
commit cf82486efa
2 changed files with 60 additions and 35 deletions

View File

@ -25,13 +25,12 @@ class GetPollsUseCase @Inject constructor() {
fun execute(): Flow<List<PollSummary>> {
// TODO unmock and add unit tests
return getActivePolls()
return flowOf(getActivePolls() + getEndedPolls())
.map { it.sortedByDescending { poll -> poll.creationTimestamp } }
}
private fun getActivePolls(): Flow<List<PollSummary.ActivePoll>> {
return flowOf(
listOf(
private fun getActivePolls(): List<PollSummary.ActivePoll> {
return listOf(
PollSummary.ActivePoll(
id = "id1",
// 2022/06/28 UTC+1
@ -57,6 +56,28 @@ class GetPollsUseCase @Inject constructor() {
title = "What film should we show at the end of the year party?"
),
)
}
private fun getEndedPolls(): List<PollSummary.EndedPoll> {
return listOf(
PollSummary.EndedPoll(
id = "id1-ended",
// 2022/06/28 UTC+1
creationTimestamp = 1656367200000,
title = "Which charity would you like to support?"
),
PollSummary.EndedPoll(
id = "id2-ended",
// 2022/06/26 UTC+1
creationTimestamp = 1656194400000,
title = "Where should we do the offsite?"
),
PollSummary.EndedPoll(
id = "id3-ended",
// 2022/06/24 UTC+1
creationTimestamp = 1656021600000,
title = "What type of food should we have at the party?"
),
)
}
}

View File

@ -17,15 +17,19 @@
package im.vector.app.features.roomprofile.polls
sealed interface PollSummary {
val id: String
val creationTimestamp: Long
val title: String
data class ActivePoll(
val id: String,
val creationTimestamp: Long,
val title: String,
override val id: String,
override val creationTimestamp: Long,
override val title: String,
) : PollSummary
data class EndedPoll(
val id: String,
val creationTimestamp: Long,
val title: String,
override val id: String,
override val creationTimestamp: Long,
override val title: String,
) : PollSummary
}