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
|
acceptButton.isEnabled = false
|
||||||
rejectButton.isEnabled = false
|
rejectButton.isEnabled = false
|
||||||
|
|
||||||
let request = Account.rejectFollowRequest(account)
|
Task {
|
||||||
mastodonController.run(request) { (response) in
|
let request = Account.rejectFollowRequest(account)
|
||||||
guard case .success(_, _) = response else { fatalError() }
|
do {
|
||||||
DispatchQueue.main.async {
|
_ = try await mastodonController.run(request)
|
||||||
|
|
||||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
||||||
self.actionButtonsStackView.isHidden = true
|
self.actionButtonsStackView.isHidden = true
|
||||||
self.addLabel(NSLocalizedString("Rejected", comment: "rejected follow request label"))
|
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
|
acceptButton.isEnabled = false
|
||||||
rejectButton.isEnabled = false
|
rejectButton.isEnabled = false
|
||||||
|
|
||||||
let request = Account.authorizeFollowRequest(account)
|
Task {
|
||||||
mastodonController.run(request) { (response) in
|
let request = Account.authorizeFollowRequest(account)
|
||||||
guard case .success(_, _) = response else { fatalError() }
|
do {
|
||||||
DispatchQueue.main.async {
|
_ = try await mastodonController.run(request)
|
||||||
|
|
||||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
||||||
self.actionButtonsStackView.isHidden = true
|
self.actionButtonsStackView.isHidden = true
|
||||||
self.addLabel(NSLocalizedString("Accepted", comment: "accepted follow request label"))
|
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