forked from shadowfacts/Tusker
Cleanup un/follow menu action
This commit is contained in:
parent
7c9287543c
commit
40f5be28f6
|
@ -63,25 +63,28 @@ extension MenuPreviewProvider {
|
||||||
let request = Client.getRelationships(accounts: [account.id])
|
let request = Client.getRelationships(accounts: [account.id])
|
||||||
// talk about callback hell :/
|
// talk about callback hell :/
|
||||||
mastodonController.run(request) { [weak self] (response) in
|
mastodonController.run(request) { [weak self] (response) in
|
||||||
if let self = self,
|
guard let self = self,
|
||||||
case let .success(results, _) = response,
|
case let .success(results, _) = response,
|
||||||
let relationship = results.first {
|
let relationship = results.first else {
|
||||||
let following = relationship.following
|
elementHandler([])
|
||||||
DispatchQueue.main.async {
|
return
|
||||||
elementHandler([
|
}
|
||||||
self.createAction(identifier: "follow", title: following ? "Unfollow" : "Follow", systemImageName: following ? "person.badge.minus" : "person.badge.plus", handler: { (_) in
|
let following = relationship.following
|
||||||
let request = (following ? Account.unfollow : Account.follow)(accountID)
|
DispatchQueue.main.async {
|
||||||
mastodonController.run(request) { (response) in
|
let action = self.createAction(identifier: "follow", title: following ? "Unfollow" : "Follow", systemImageName: following ? "person.badge.minus" : "person.badge.plus", handler: { (_) in
|
||||||
switch response {
|
let request = (following ? Account.unfollow : Account.follow)(accountID)
|
||||||
case .failure(_):
|
mastodonController.run(request) { (response) in
|
||||||
fatalError()
|
switch response {
|
||||||
case let .success(relationship, _):
|
case .failure(_):
|
||||||
mastodonController.persistentContainer.addOrUpdate(relationship: relationship)
|
fatalError()
|
||||||
}
|
case let .success(relationship, _):
|
||||||
}
|
mastodonController.persistentContainer.addOrUpdate(relationship: relationship)
|
||||||
})
|
}
|
||||||
])
|
}
|
||||||
}
|
})
|
||||||
|
elementHandler([
|
||||||
|
action
|
||||||
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Reference in New Issue