Fix cancel follow request state

This commit is contained in:
Justin Mazzocchi 2021-02-05 20:47:20 -08:00
parent aa9842f283
commit ec20a3072f
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
2 changed files with 9 additions and 3 deletions

View file

@ -25,6 +25,7 @@
"account.mute" = "Mute";
"account.reject-follow-request-button.accessibility-label" = "Reject follow request";
"account.request" = "Request";
"account.request.cancel" = "Cancel follow request";
"account.statuses.post" = "Posts";
"account.statuses.toot" = "Toots";
"account.statuses-and-replies.post" = "Posts & Replies";

View file

@ -53,8 +53,13 @@ final class AccountHeaderView: UIView {
accountViewModel.isLocked ? "account.request" : "account.follow",
comment: ""),
for: .normal)
followButton.isHidden = relationship.following
unfollowButton.isHidden = !relationship.following
followButton.isHidden = relationship.following || relationship.requested
unfollowButton.isHidden = !(relationship.following || relationship.requested)
unfollowButton.setTitle(
NSLocalizedString(
relationship.requested ? "account.request.cancel" : "account.unfollow",
comment: ""),
for: .normal)
relationshipButtonsStackView.isHidden = false
unavailableLabel.isHidden = !relationship.blockedBy
@ -269,7 +274,7 @@ private extension AccountHeaderView {
guard let accountViewModel = self?.viewModel.accountViewModel else { return }
let unfollowAction = UIAction(
title: NSLocalizedString("account.unfollow", comment: ""),
title: self?.unfollowButton.title(for: .normal) ?? "",
image: UIImage(systemName: "person.badge.minus"),
attributes: .destructive) { _ in
accountViewModel.unfollow()