Update option progress when selected
This commit is contained in:
parent
161402d501
commit
c1d2114b60
1 changed files with 8 additions and 2 deletions
|
|
@ -40,10 +40,16 @@ class TimelineItemContentPollFactory @Inject constructor(
|
||||||
val userVotes = content.votes.filter { matrixClient.sessionId in it.value }.keys
|
val userVotes = content.votes.filter { matrixClient.sessionId in it.value }.keys
|
||||||
val answerItems = content.answers.map { answer ->
|
val answerItems = content.answers.map { answer ->
|
||||||
val votesCount = content.votes[answer.id]?.size ?: 0
|
val votesCount = content.votes[answer.id]?.size ?: 0
|
||||||
val progress = if (content.kind.isDisclosed && pollVotesCount > 0) votesCount.toFloat() / pollVotesCount.toFloat() else 0f
|
val isSelected = answer.id in userVotes
|
||||||
|
val progress = when {
|
||||||
|
pollVotesCount == 0 -> 0f
|
||||||
|
content.kind.isDisclosed -> votesCount.toFloat() / pollVotesCount.toFloat()
|
||||||
|
isSelected -> 1f
|
||||||
|
else -> 0f
|
||||||
|
}
|
||||||
PollAnswerItem(
|
PollAnswerItem(
|
||||||
answer = answer,
|
answer = answer,
|
||||||
isSelected = answer.id in userVotes,
|
isSelected = isSelected,
|
||||||
isDisclosed = content.kind.isDisclosed,
|
isDisclosed = content.kind.isDisclosed,
|
||||||
votesCount = votesCount,
|
votesCount = votesCount,
|
||||||
progress = progress,
|
progress = progress,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue