Adding mocked data for ended polls
This commit is contained in:
parent
740591cd38
commit
cf82486efa
@ -25,38 +25,59 @@ class GetPollsUseCase @Inject constructor() {
|
|||||||
|
|
||||||
fun execute(): Flow<List<PollSummary>> {
|
fun execute(): Flow<List<PollSummary>> {
|
||||||
// TODO unmock and add unit tests
|
// TODO unmock and add unit tests
|
||||||
return getActivePolls()
|
return flowOf(getActivePolls() + getEndedPolls())
|
||||||
.map { it.sortedByDescending { poll -> poll.creationTimestamp } }
|
.map { it.sortedByDescending { poll -> poll.creationTimestamp } }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getActivePolls(): Flow<List<PollSummary.ActivePoll>> {
|
private fun getActivePolls(): List<PollSummary.ActivePoll> {
|
||||||
return flowOf(
|
return listOf(
|
||||||
listOf(
|
PollSummary.ActivePoll(
|
||||||
PollSummary.ActivePoll(
|
id = "id1",
|
||||||
id = "id1",
|
// 2022/06/28 UTC+1
|
||||||
// 2022/06/28 UTC+1
|
creationTimestamp = 1656367200000,
|
||||||
creationTimestamp = 1656367200000,
|
title = "Which charity would you like to support?"
|
||||||
title = "Which charity would you like to support?"
|
),
|
||||||
),
|
PollSummary.ActivePoll(
|
||||||
PollSummary.ActivePoll(
|
id = "id2",
|
||||||
id = "id2",
|
// 2022/06/26 UTC+1
|
||||||
// 2022/06/26 UTC+1
|
creationTimestamp = 1656194400000,
|
||||||
creationTimestamp = 1656194400000,
|
title = "Which sport should the pupils do this year?"
|
||||||
title = "Which sport should the pupils do this year?"
|
),
|
||||||
),
|
PollSummary.ActivePoll(
|
||||||
PollSummary.ActivePoll(
|
id = "id3",
|
||||||
id = "id3",
|
// 2022/06/24 UTC+1
|
||||||
// 2022/06/24 UTC+1
|
creationTimestamp = 1656021600000,
|
||||||
creationTimestamp = 1656021600000,
|
title = "What type of food should we have at the party?"
|
||||||
title = "What type of food should we have at the party?"
|
),
|
||||||
),
|
PollSummary.ActivePoll(
|
||||||
PollSummary.ActivePoll(
|
id = "id4",
|
||||||
id = "id4",
|
// 2022/06/22 UTC+1
|
||||||
// 2022/06/22 UTC+1
|
creationTimestamp = 1655848800000,
|
||||||
creationTimestamp = 1655848800000,
|
title = "What film should we show at the end of the year party?"
|
||||||
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?"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,19 @@
|
|||||||
package im.vector.app.features.roomprofile.polls
|
package im.vector.app.features.roomprofile.polls
|
||||||
|
|
||||||
sealed interface PollSummary {
|
sealed interface PollSummary {
|
||||||
|
val id: String
|
||||||
|
val creationTimestamp: Long
|
||||||
|
val title: String
|
||||||
|
|
||||||
data class ActivePoll(
|
data class ActivePoll(
|
||||||
val id: String,
|
override val id: String,
|
||||||
val creationTimestamp: Long,
|
override val creationTimestamp: Long,
|
||||||
val title: String,
|
override val title: String,
|
||||||
) : PollSummary
|
) : PollSummary
|
||||||
|
|
||||||
data class EndedPoll(
|
data class EndedPoll(
|
||||||
val id: String,
|
override val id: String,
|
||||||
val creationTimestamp: Long,
|
override val creationTimestamp: Long,
|
||||||
val title: String,
|
override val title: String,
|
||||||
) : PollSummary
|
) : PollSummary
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user