From 393a134648201a4ff32b56bb2490502ac3abe436 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 19 Jun 2020 23:00:59 -0400 Subject: [PATCH] Don't show Follow activity for user's own account --- .../Profile/ProfileTableViewController.swift | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/Tusker/Screens/Profile/ProfileTableViewController.swift b/Tusker/Screens/Profile/ProfileTableViewController.swift index 36a9976b14..33befb6ca5 100644 --- a/Tusker/Screens/Profile/ProfileTableViewController.swift +++ b/Tusker/Screens/Profile/ProfileTableViewController.swift @@ -303,19 +303,27 @@ extension ProfileTableViewController: ProfileHeaderTableViewCellDelegate { func showMoreOptions(cell: ProfileHeaderTableViewCell) { let account = mastodonController.persistentContainer.account(for: accountID)! - let request = Client.getRelationships(accounts: [account.id]) - mastodonController.run(request) { (response) in - var customActivities: [UIActivity] = [OpenInSafariActivity()] - if case let .success(results, _) = response, let relationship = results.first { - let toggleFollowActivity = relationship.following ? UnfollowAccountActivity() : FollowAccountActivity() - customActivities.insert(toggleFollowActivity, at: 0) - } - - DispatchQueue.main.async { - let activityController = UIActivityViewController(activityItems: [account.url, AccountActivityItemSource(account)], applicationActivities: customActivities) - activityController.completionWithItemsHandler = OpenInSafariActivity.completionHandler(viewController: self, url: account.url) - activityController.popoverPresentationController?.sourceView = cell.moreButtonVisualEffectView - self.present(activityController, animated: true) + func showActivityController(activities: [UIActivity]) { + let activityController = UIActivityViewController(activityItems: [account.url, AccountActivityItemSource(account)], applicationActivities: activities) + activityController.completionWithItemsHandler = OpenInSafariActivity.completionHandler(viewController: self, url: account.url) + activityController.popoverPresentationController?.sourceView = cell.moreButtonVisualEffectView + self.present(activityController, animated: true) + } + + if account.id == mastodonController.account.id { + showActivityController(activities: [OpenInSafariActivity()]) + } else { + let request = Client.getRelationships(accounts: [account.id]) + mastodonController.run(request) { (response) in + var customActivities: [UIActivity] = [OpenInSafariActivity()] + if case let .success(results, _) = response, let relationship = results.first { + let toggleFollowActivity = relationship.following ? UnfollowAccountActivity() : FollowAccountActivity() + customActivities.insert(toggleFollowActivity, at: 0) + } + + DispatchQueue.main.async { + showActivityController(activities: customActivities) + } } } }