2
2
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:
shannon 2025-01-22 15:45:12 -05:00
parent e91d6e3bc5
commit 537f6cc5fd
3 changed files with 6 additions and 3 deletions

View File

@ -56,7 +56,7 @@ extension DataSourceFacade {
continuation.resume(returning: relationship)
} else {
continuation.resume(throwing: AppError.unexpected)
continuation.resume(throwing: AppError.unexpected())
}
}
alert.addAction(cancel)

View File

@ -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
}

View File

@ -10,5 +10,5 @@ import Foundation
public enum AppError: Error {
case badRequest
case badAuthentication
case unexpected
case unexpected(String? = nil)
}