Browse Source

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

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 2 years ago
parent
commit
0388f3e3f6

+ 4 - 1
app/src/main/java/com/nextcloud/talk/polls/ui/PollResultsFragment.kt

@@ -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)