forked from shadowfacts/Tusker
Don't show Follow activity for user's own account
This commit is contained in:
parent
ba3e9e7491
commit
393a134648
|
@ -303,19 +303,27 @@ extension ProfileTableViewController: ProfileHeaderTableViewCellDelegate {
|
||||||
func showMoreOptions(cell: ProfileHeaderTableViewCell) {
|
func showMoreOptions(cell: ProfileHeaderTableViewCell) {
|
||||||
let account = mastodonController.persistentContainer.account(for: accountID)!
|
let account = mastodonController.persistentContainer.account(for: accountID)!
|
||||||
|
|
||||||
let request = Client.getRelationships(accounts: [account.id])
|
func showActivityController(activities: [UIActivity]) {
|
||||||
mastodonController.run(request) { (response) in
|
let activityController = UIActivityViewController(activityItems: [account.url, AccountActivityItemSource(account)], applicationActivities: activities)
|
||||||
var customActivities: [UIActivity] = [OpenInSafariActivity()]
|
activityController.completionWithItemsHandler = OpenInSafariActivity.completionHandler(viewController: self, url: account.url)
|
||||||
if case let .success(results, _) = response, let relationship = results.first {
|
activityController.popoverPresentationController?.sourceView = cell.moreButtonVisualEffectView
|
||||||
let toggleFollowActivity = relationship.following ? UnfollowAccountActivity() : FollowAccountActivity()
|
self.present(activityController, animated: true)
|
||||||
customActivities.insert(toggleFollowActivity, at: 0)
|
}
|
||||||
}
|
|
||||||
|
if account.id == mastodonController.account.id {
|
||||||
DispatchQueue.main.async {
|
showActivityController(activities: [OpenInSafariActivity()])
|
||||||
let activityController = UIActivityViewController(activityItems: [account.url, AccountActivityItemSource(account)], applicationActivities: customActivities)
|
} else {
|
||||||
activityController.completionWithItemsHandler = OpenInSafariActivity.completionHandler(viewController: self, url: account.url)
|
let request = Client.getRelationships(accounts: [account.id])
|
||||||
activityController.popoverPresentationController?.sourceView = cell.moreButtonVisualEffectView
|
mastodonController.run(request) { (response) in
|
||||||
self.present(activityController, animated: true)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue