forked from shadowfacts/Tusker
Fix crash when accept/reject follow request fails
This commit is contained in:
parent
ddcb13dd28
commit
1e2947ceba
|
@ -134,13 +134,24 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
|||
acceptButton.isEnabled = false
|
||||
rejectButton.isEnabled = false
|
||||
|
||||
Task {
|
||||
let request = Account.rejectFollowRequest(account)
|
||||
mastodonController.run(request) { (response) in
|
||||
guard case .success(_, _) = response else { fatalError() }
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
_ = try await mastodonController.run(request)
|
||||
|
||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
||||
self.actionButtonsStackView.isHidden = true
|
||||
self.addLabel(NSLocalizedString("Rejected", comment: "rejected follow request label"))
|
||||
} catch let error as Client.Error {
|
||||
acceptButton.isEnabled = true
|
||||
rejectButton.isEnabled = true
|
||||
if let toastable = delegate?.toastableViewController {
|
||||
let config = ToastConfiguration(from: error, with: "Rejecting Follow", in: toastable) { [weak self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
self?.rejectButtonPressed()
|
||||
}
|
||||
toastable.showToast(configuration: config, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,13 +160,25 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
|||
acceptButton.isEnabled = false
|
||||
rejectButton.isEnabled = false
|
||||
|
||||
Task {
|
||||
let request = Account.authorizeFollowRequest(account)
|
||||
mastodonController.run(request) { (response) in
|
||||
guard case .success(_, _) = response else { fatalError() }
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
_ = try await mastodonController.run(request)
|
||||
|
||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
||||
self.actionButtonsStackView.isHidden = true
|
||||
self.addLabel(NSLocalizedString("Accepted", comment: "accepted follow request label"))
|
||||
} catch let error as Client.Error {
|
||||
acceptButton.isEnabled = true
|
||||
rejectButton.isEnabled = true
|
||||
|
||||
if let toastable = delegate?.toastableViewController {
|
||||
let config = ToastConfiguration(from: error, with: "Accepting Follow", in: toastable) { [weak self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
self?.acceptButtonPressed()
|
||||
}
|
||||
toastable.showToast(configuration: config, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue