mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-01-23 06:02:35 +01:00
Fix voted indicator on poll missing (IOS-274) (#1301)
# Rationale Fixes #1289
This commit is contained in:
commit
e2c1cf301a
@ -144,7 +144,6 @@ extension StatusSection {
|
||||
authContext: AuthContext,
|
||||
statusView: StatusView
|
||||
) {
|
||||
let managedObjectContext = context.managedObjectContext
|
||||
statusView.pollTableViewDiffableDataSource = UITableViewDiffableDataSource<PollSection, PollItem>(tableView: statusView.pollTableView) { tableView, indexPath, item in
|
||||
switch item {
|
||||
case .history:
|
||||
|
@ -56,14 +56,17 @@ public final class MastodonPollOption: ObservableObject, Hashable {
|
||||
@Published public var voted: Bool?
|
||||
public private(set) var optionIndex: Int? = nil
|
||||
|
||||
public init(poll: MastodonPoll, option: Mastodon.Entity.Poll.Option, isSelected: Bool = false) {
|
||||
public init(poll: MastodonPoll, option: Mastodon.Entity.Poll.Option) {
|
||||
self.poll = poll
|
||||
self.option = option
|
||||
self.isSelected = isSelected
|
||||
self.votesCount = option.votesCount
|
||||
self.title = option.title
|
||||
self.optionIndex = poll.options.firstIndex(of: self)
|
||||
|
||||
self.isSelected = {
|
||||
guard let ownVotes = poll.entity.ownVotes else { return false }
|
||||
guard let index = poll.entity.options.firstIndex(of: option) else { return false }
|
||||
return ownVotes.contains(index)
|
||||
}()
|
||||
self.voted = {
|
||||
guard let ownVotes = poll.entity.ownVotes else { return false }
|
||||
guard let optionIndex else { return false }
|
||||
|
Loading…
Reference in New Issue
Block a user