Properly update button-state when following people (IOS-194)
This commit is contained in:
parent
601d52c28f
commit
6cf5134ff6
|
@ -30,15 +30,18 @@ extension DataSourceFacade {
|
|||
static func responseToUserFollowAction(
|
||||
dependency: NeedsDependency & AuthContextProvider,
|
||||
user: Mastodon.Entity.Account
|
||||
) async throws {
|
||||
) async throws -> Mastodon.Entity.Relationship {
|
||||
let selectionFeedbackGenerator = await UISelectionFeedbackGenerator()
|
||||
await selectionFeedbackGenerator.selectionChanged()
|
||||
|
||||
_ = try await dependency.context.apiService.toggleFollow(
|
||||
let response = try await dependency.context.apiService.toggleFollow(
|
||||
user: user,
|
||||
authenticationBox: dependency.authContext.mastodonAuthenticationBox
|
||||
)
|
||||
).value
|
||||
|
||||
dependency.context.authenticationService.fetchFollowingAndBlockedAsync()
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -115,8 +115,14 @@ extension DiscoveryForYouViewController: ProfileCardTableViewCellDelegate {
|
|||
guard let indexPath = tableView.indexPath(for: cell) else { return }
|
||||
guard case let .account(account, _) = viewModel.diffableDataSource?.itemIdentifier(for: indexPath) else { return }
|
||||
|
||||
cell.profileCardView.setButtonState(.loading)
|
||||
|
||||
Task {
|
||||
try await DataSourceFacade.responseToUserFollowAction(dependency: self, user: account)
|
||||
let newRelationship = try await DataSourceFacade.responseToUserFollowAction(dependency: self, user: account)
|
||||
|
||||
await MainActor.run {
|
||||
cell.profileCardView.updateButtonState(with: newRelationship, isMe: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue