2022-01-27 14:23:39 +01:00
|
|
|
//
|
|
|
|
// DataSourceFacade+Thread.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-1-17.
|
|
|
|
//
|
|
|
|
|
2023-09-17 17:27:42 +02:00
|
|
|
import UIKit
|
2022-01-27 14:23:39 +01:00
|
|
|
import CoreData
|
|
|
|
import CoreDataStack
|
2022-10-09 14:07:57 +02:00
|
|
|
import MastodonCore
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
extension DataSourceFacade {
|
|
|
|
static func coordinateToStatusThreadScene(
|
2023-09-17 17:27:42 +02:00
|
|
|
provider: NeedsDependency & UIViewController & AuthContextProvider,
|
2022-01-27 14:23:39 +01:00
|
|
|
target: StatusTarget,
|
|
|
|
status: ManagedObjectRecord<Status>
|
|
|
|
) async {
|
|
|
|
let _root: StatusItem.Thread? = await {
|
|
|
|
let _redirectRecord = await DataSourceFacade.status(
|
|
|
|
managedObjectContext: provider.context.managedObjectContext,
|
|
|
|
status: status,
|
|
|
|
target: target
|
|
|
|
)
|
|
|
|
guard let redirectRecord = _redirectRecord else { return nil }
|
|
|
|
|
|
|
|
let threadContext = StatusItem.Thread.Context(status: redirectRecord)
|
|
|
|
return StatusItem.Thread.root(context: threadContext)
|
|
|
|
}()
|
|
|
|
guard let root = _root else {
|
|
|
|
assertionFailure()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
await coordinateToStatusThreadScene(
|
|
|
|
provider: provider,
|
|
|
|
root: root
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainActor
|
|
|
|
static func coordinateToStatusThreadScene(
|
2023-09-17 17:27:42 +02:00
|
|
|
provider: NeedsDependency & UIViewController & AuthContextProvider,
|
2022-01-27 14:23:39 +01:00
|
|
|
root: StatusItem.Thread
|
|
|
|
) async {
|
|
|
|
let threadViewModel = ThreadViewModel(
|
|
|
|
context: provider.context,
|
2022-10-09 14:07:57 +02:00
|
|
|
authContext: provider.authContext,
|
2022-01-27 14:23:39 +01:00
|
|
|
optionalRoot: root
|
|
|
|
)
|
2022-10-09 14:07:57 +02:00
|
|
|
_ = provider.coordinator.present(
|
2022-01-27 14:23:39 +01:00
|
|
|
scene: .thread(viewModel: threadViewModel),
|
|
|
|
from: provider,
|
|
|
|
transition: .show
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|