mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Alert user to any error in poll vote processing; always resolve activity indicator.
Contributes to #1123 [BUG] App crashes when voting on a poll
This commit is contained in:
parent
e91d6e3bc5
commit
537f6cc5fd
@ -56,7 +56,7 @@ extension DataSourceFacade {
|
||||
|
||||
continuation.resume(returning: relationship)
|
||||
} else {
|
||||
continuation.resume(throwing: AppError.unexpected)
|
||||
continuation.resume(throwing: AppError.unexpected())
|
||||
}
|
||||
}
|
||||
alert.addAction(cancel)
|
||||
|
@ -315,13 +315,16 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte
|
||||
authenticationBox: authenticationBox
|
||||
).value
|
||||
|
||||
guard let entity = poll.status?.entity else { return }
|
||||
guard let entity = poll.status?.entity else { throw AppError.unexpected("Poll vote recorded but could not be updated in view") }
|
||||
|
||||
let newStatus: MastodonStatus = .fromEntity(entity)
|
||||
newStatus.poll = MastodonPoll(poll: newPoll, status: newStatus)
|
||||
|
||||
self.update(status: newStatus, intent: .pollVote)
|
||||
} catch {
|
||||
let alert = UIAlertController(title: "Poll Error", message: "Something went wrong while processing your response: \(error)", preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .cancel))
|
||||
self.sceneCoordinator?.tabBarController.showAlert(alert)
|
||||
statusView.viewModel.isVoting = false
|
||||
}
|
||||
|
||||
|
@ -10,5 +10,5 @@ import Foundation
|
||||
public enum AppError: Error {
|
||||
case badRequest
|
||||
case badAuthentication
|
||||
case unexpected
|
||||
case unexpected(String? = nil)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user