diff --git a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift index ff0fb6b7ae..1438a36120 100644 --- a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift +++ b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.swift @@ -104,36 +104,42 @@ class FollowRequestNotificationTableViewCell: UITableViewCell { updateTimestampWorkItem = nil } + private func addLabel(_ text: String) { + let label = UILabel() + label.textAlignment = .center + label.font = .boldSystemFont(ofSize: 17) + label.text = text + self.stackView.addArrangedSubview(label) + } + // MARK: - Interaction @IBAction func rejectButtonPressed() { + acceptButton.isEnabled = false + rejectButton.isEnabled = false + let request = Account.rejectFollowRequest(account) mastodonController.run(request) { (response) in guard case .success(_, _) = response else { fatalError() } DispatchQueue.main.async { UINotificationFeedbackGenerator().notificationOccurred(.success) self.actionButtonsStackView.isHidden = true - let label = UILabel() - label.textAlignment = .center - label.font = .boldSystemFont(ofSize: 17) - label.text = NSLocalizedString("Rejected", comment: "rejected follow request label") - self.stackView.addArrangedSubview(label) + self.addLabel(NSLocalizedString("Rejected", comment: "rejected follow request label")) } } } @IBAction func acceptButtonPressed() { + acceptButton.isEnabled = false + rejectButton.isEnabled = false + let request = Account.authorizeFollowRequest(account) mastodonController.run(request) { (response) in guard case .success(_, _) = response else { fatalError() } DispatchQueue.main.async { UINotificationFeedbackGenerator().notificationOccurred(.success) self.actionButtonsStackView.isHidden = true - let label = UILabel() - label.textAlignment = .center - label.font = .boldSystemFont(ofSize: 17) - label.text = NSLocalizedString("Accepted", comment: "accepted follow request label") - self.stackView.addArrangedSubview(label) + self.addLabel(NSLocalizedString("Accepted", comment: "accepted follow request label")) } } } diff --git a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.xib b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.xib index 55abf8f761..be1f165dce 100644 --- a/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.xib +++ b/Tusker/Views/Notifications/FollowRequestNotificationTableViewCell.xib @@ -1,9 +1,11 @@ - + - + + + @@ -30,12 +32,12 @@ - + @@ -49,19 +51,20 @@ - -