mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-02-02 18:36:44 +01:00
Move task and async/await to call-site (IOS-192)
This commit is contained in:
parent
97d1ab4e5b
commit
e70a67caf0
@ -41,6 +41,7 @@ extension DataSourceFacade {
|
||||
assertionFailure()
|
||||
return
|
||||
}
|
||||
|
||||
await coordinateToProfileScene(
|
||||
provider: provider,
|
||||
account: redirectRecord
|
||||
@ -100,30 +101,26 @@ extension DataSourceFacade {
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static func coordinateToProfileScene(
|
||||
public static func coordinateToProfileScene(
|
||||
provider: ViewControllerWithDependencies & AuthContextProvider,
|
||||
account: Mastodon.Entity.Account
|
||||
) {
|
||||
) async {
|
||||
guard let me = provider.authContext.mastodonAuthenticationBox.authentication.account(),
|
||||
let relationship = try? await provider.context.apiService.relationship(forAccounts: [account], authenticationBox: provider.authContext.mastodonAuthenticationBox).value.first else { return }
|
||||
|
||||
Task { @MainActor in
|
||||
let profileViewModel = ProfileViewModel(
|
||||
context: provider.context,
|
||||
authContext: provider.authContext,
|
||||
account: account,
|
||||
relationship: relationship,
|
||||
me: me
|
||||
)
|
||||
|
||||
guard let me = provider.authContext.mastodonAuthenticationBox.authentication.account(),
|
||||
let relationship = try? await provider.context.apiService.relationship(forAccounts: [account], authenticationBox: provider.authContext.mastodonAuthenticationBox).value.first else { return }
|
||||
|
||||
let profileViewModel = ProfileViewModel(
|
||||
context: provider.context,
|
||||
authContext: provider.authContext,
|
||||
account: account,
|
||||
relationship: relationship,
|
||||
me: me
|
||||
)
|
||||
|
||||
_ = provider.coordinator.present(
|
||||
scene: .profile(viewModel: profileViewModel),
|
||||
from: provider,
|
||||
transition: .show
|
||||
)
|
||||
}
|
||||
_ = provider.coordinator.present(
|
||||
scene: .profile(viewModel: profileViewModel),
|
||||
from: provider,
|
||||
transition: .show
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ extension UITableViewDelegate where Self: DataSourceProvider & AuthContextProvid
|
||||
}
|
||||
switch item {
|
||||
case .account(let account, relationship: _):
|
||||
DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
await DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
case .status(let status):
|
||||
await DataSourceFacade.coordinateToStatusThreadScene(
|
||||
provider: self,
|
||||
|
@ -99,7 +99,9 @@ extension DiscoveryForYouViewController: UITableViewDelegate {
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
guard case let .account(account, _) = viewModel.diffableDataSource?.itemIdentifier(for: indexPath) else { return }
|
||||
|
||||
DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
Task {
|
||||
await DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ extension NotificationTimelineViewController: TableViewControllerNavigateable {
|
||||
)
|
||||
} else {
|
||||
|
||||
DataSourceFacade.coordinateToProfileScene(provider: self, account: notification.account)
|
||||
await DataSourceFacade.coordinateToProfileScene(provider: self, account: notification.account)
|
||||
}
|
||||
default:
|
||||
break
|
||||
|
@ -75,7 +75,7 @@ extension SearchHistoryViewController: UICollectionViewDelegate {
|
||||
|
||||
switch item {
|
||||
case .account(account: let account, relationship: _):
|
||||
DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
await DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
|
||||
case .hashtag(let tag):
|
||||
await DataSourceFacade.coordinateToHashtagScene(
|
||||
|
@ -62,7 +62,7 @@ extension SearchResultViewController {
|
||||
|
||||
switch item {
|
||||
case .account(let account, relationship: _):
|
||||
DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
await DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
case .status(let status):
|
||||
await DataSourceFacade.coordinateToStatusThreadScene(
|
||||
provider: self,
|
||||
|
@ -216,8 +216,11 @@ extension SettingsCoordinator: ServerDetailsViewControllerDelegate {
|
||||
}
|
||||
|
||||
extension SettingsCoordinator: AboutInstanceViewControllerDelegate {
|
||||
@MainActor func showAdminAccount(_ viewController: AboutInstanceViewController, account: Mastodon.Entity.Account) {
|
||||
DataSourceFacade.coordinateToProfileScene(provider: viewController, account: account)
|
||||
@MainActor
|
||||
func showAdminAccount(_ viewController: AboutInstanceViewController, account: Mastodon.Entity.Account) {
|
||||
Task {
|
||||
await DataSourceFacade.coordinateToProfileScene(provider: viewController, account: account)
|
||||
}
|
||||
}
|
||||
|
||||
func sendEmailToAdmin(_ viewController: AboutInstanceViewController, emailAddress: String) {
|
||||
|
@ -90,8 +90,10 @@ extension SuggestionAccountViewController: UITableViewDelegate {
|
||||
guard let tableViewDiffableDataSource = viewModel.tableViewDiffableDataSource else { return }
|
||||
guard let item = tableViewDiffableDataSource.itemIdentifier(for: indexPath) else { return }
|
||||
switch item {
|
||||
case .account(let account, _):
|
||||
DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
case .account(let account, _):
|
||||
Task {
|
||||
await DataSourceFacade.coordinateToProfileScene(provider: self, account: account)
|
||||
}
|
||||
}
|
||||
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user