Fix crash when poll voting fails
This commit is contained in:
parent
2f75510889
commit
a2868739c2
|
@ -21,6 +21,7 @@ class StatusPollView: UIView {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
weak var mastodonController: MastodonController!
|
weak var mastodonController: MastodonController!
|
||||||
|
weak var toastableViewController: ToastableViewController?
|
||||||
|
|
||||||
private var statusID: String!
|
private var statusID: String!
|
||||||
private(set) var poll: Poll?
|
private(set) var poll: Poll?
|
||||||
|
@ -151,7 +152,14 @@ class StatusPollView: UIView {
|
||||||
mastodonController.run(request) { (response) in
|
mastodonController.run(request) { (response) in
|
||||||
switch response {
|
switch response {
|
||||||
case let .failure(error):
|
case let .failure(error):
|
||||||
fatalError("error voting in poll: \(error)")
|
DispatchQueue.main.async {
|
||||||
|
self.updateUI(status: self.mastodonController.persistentContainer.status(for: self.statusID)!, poll: self.poll)
|
||||||
|
|
||||||
|
if let toastable = self.toastableViewController {
|
||||||
|
let config = ToastConfiguration(from: error, with: "Error Voting", in: toastable, retryAction: nil)
|
||||||
|
toastable.showToast(configuration: config, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case let .success(poll, _):
|
case let .success(poll, _):
|
||||||
let container = self.mastodonController.persistentContainer
|
let container = self.mastodonController.persistentContainer
|
||||||
|
|
|
@ -211,6 +211,7 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
pollView.isHidden = status.poll == nil
|
pollView.isHidden = status.poll == nil
|
||||||
pollView.mastodonController = mastodonController
|
pollView.mastodonController = mastodonController
|
||||||
|
pollView.toastableViewController = delegate?.toastableViewController
|
||||||
pollView.updateUI(status: status, poll: status.poll)
|
pollView.updateUI(status: status, poll: status.poll)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue