fix to show vote results if only "poll.votes" are available

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-06-15 19:14:41 +02:00 committed by Andy Scherzinger (Rebase PR Action)
parent d31a9b1ade
commit 0388f3e3f6

View File

@ -115,7 +115,10 @@ class PollResultsFragment(
val oneVoteInPercent = 100 / votersAmount
poll.options?.forEachIndexed { index, option ->
val votersForThisOption = poll.votes?.filter { it.key.toInt() == index }?.size!!
var votersForThisOption = poll.votes.filter { it.key.toInt() == index }[index.toString()]
if (votersForThisOption == null) {
votersForThisOption = 0
}
val optionsPercent = oneVoteInPercent * votersForThisOption
val pollResultItem = PollResultItem(option, optionsPercent)