mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-02-06 04:13:28 +01:00
fix: Poll percentages were wrong due to wrong count being used (votes vs voters) (#834)
This commit is contained in:
parent
bb1c003228
commit
6d80df1279
@ -33,12 +33,12 @@ extension PollOptionView {
|
||||
.store(in: &disposeBag)
|
||||
// percentage
|
||||
Publishers.CombineLatest(
|
||||
option.poll.publisher(for: \.votesCount),
|
||||
option.poll.publisher(for: \.votersCount),
|
||||
option.publisher(for: \.votesCount)
|
||||
)
|
||||
.map { pollVotesCount, optionVotesCount -> Double? in
|
||||
guard pollVotesCount > 0, optionVotesCount >= 0 else { return 0 }
|
||||
return Double(optionVotesCount) / Double(pollVotesCount)
|
||||
.map { pollVotersCount, optionVotesCount -> Double? in
|
||||
guard pollVotersCount > 0, optionVotesCount >= 0 else { return 0 }
|
||||
return Double(optionVotesCount) / Double(pollVotersCount)
|
||||
}
|
||||
.assign(to: \.percentage, on: viewModel)
|
||||
.store(in: &disposeBag)
|
||||
|
@ -175,7 +175,7 @@ extension PollOptionView.ViewModel {
|
||||
view.voteProgressStripView.setProgress(0.0, animated: false)
|
||||
case .reveal(let voted, let percentage, let animating):
|
||||
view.optionPercentageLabel.isHidden = false
|
||||
view.optionPercentageLabel.text = String(Int(100 * percentage)) + "%"
|
||||
view.optionPercentageLabel.text = String(Int(round(100 * percentage))) + "%"
|
||||
view.voteProgressStripView.isHidden = false
|
||||
view.voteProgressStripView.tintColor = voted ? self.primaryStripProgressViewTintColor : self.secondaryStripProgressViewTintColor
|
||||
view.voteProgressStripView.setProgress(CGFloat(percentage), animated: animating)
|
||||
|
Loading…
x
Reference in New Issue
Block a user