Renaming
This commit is contained in:
parent
18d1b61101
commit
9ac6ed2d93
|
@ -9,27 +9,27 @@ import MastodonAPI
|
||||||
public struct ContextService {
|
public struct ContextService {
|
||||||
public let sections: AnyPublisher<[[CollectionItem]], Error>
|
public let sections: AnyPublisher<[[CollectionItem]], Error>
|
||||||
public let navigationService: NavigationService
|
public let navigationService: NavigationService
|
||||||
public var contextParentID: String? { statusID }
|
public var contextParentID: String? { parentID }
|
||||||
|
|
||||||
private let statusID: String
|
private let parentID: String
|
||||||
private let mastodonAPIClient: MastodonAPIClient
|
private let mastodonAPIClient: MastodonAPIClient
|
||||||
private let contentDatabase: ContentDatabase
|
private let contentDatabase: ContentDatabase
|
||||||
|
|
||||||
init(statusID: String, mastodonAPIClient: MastodonAPIClient, contentDatabase: ContentDatabase) {
|
init(parentID: String, mastodonAPIClient: MastodonAPIClient, contentDatabase: ContentDatabase) {
|
||||||
self.statusID = statusID
|
self.parentID = parentID
|
||||||
self.mastodonAPIClient = mastodonAPIClient
|
self.mastodonAPIClient = mastodonAPIClient
|
||||||
self.contentDatabase = contentDatabase
|
self.contentDatabase = contentDatabase
|
||||||
sections = contentDatabase.contextObservation(parentID: statusID)
|
sections = contentDatabase.contextObservation(parentID: parentID)
|
||||||
navigationService = NavigationService(mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
navigationService = NavigationService(mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ContextService: CollectionService {
|
extension ContextService: CollectionService {
|
||||||
public func request(maxID: String?, minID: String?) -> AnyPublisher<Never, Error> {
|
public func request(maxID: String?, minID: String?) -> AnyPublisher<Never, Error> {
|
||||||
mastodonAPIClient.request(StatusEndpoint.status(id: statusID))
|
mastodonAPIClient.request(StatusEndpoint.status(id: parentID))
|
||||||
.flatMap(contentDatabase.insert(status:))
|
.flatMap(contentDatabase.insert(status:))
|
||||||
.merge(with: mastodonAPIClient.request(ContextEndpoint.context(id: statusID))
|
.merge(with: mastodonAPIClient.request(ContextEndpoint.context(id: parentID))
|
||||||
.flatMap { contentDatabase.insert(context: $0, parentID: statusID) })
|
.flatMap { contentDatabase.insert(context: $0, parentID: parentID) })
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public extension NavigationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
func contextService(id: String) -> ContextService {
|
func contextService(id: String) -> ContextService {
|
||||||
ContextService(statusID: id, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
ContextService(parentID: id, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func profileService(id: String) -> ProfileService {
|
func profileService(id: String) -> ProfileService {
|
||||||
|
|
Loading…
Reference in New Issue