Refactoring

This commit is contained in:
Justin Mazzocchi 2020-10-05 12:58:03 -07:00
parent f1f49b7c3f
commit 2040c0dc6d
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
6 changed files with 10 additions and 21 deletions

View file

@ -26,10 +26,7 @@ public struct AccountListService {
.map { [$0.map(CollectionItem.account)] }
.eraseToAnyPublisher()
nextPageMaxIDs = nextPageMaxIDsSubject.eraseToAnyPublisher()
navigationService = NavigationService(
status: nil,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase)
navigationService = NavigationService(mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
}
}

View file

@ -9,15 +9,13 @@ import MastodonAPI
public struct AccountService {
public let account: Account
public let navigationService: NavigationService
private let mastodonAPIClient: MastodonAPIClient
private let contentDatabase: ContentDatabase
init(account: Account, mastodonAPIClient: MastodonAPIClient, contentDatabase: ContentDatabase) {
self.account = account
self.navigationService = NavigationService(
status: nil,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase)
navigationService = NavigationService(mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
self.mastodonAPIClient = mastodonAPIClient
self.contentDatabase = contentDatabase
}

View file

@ -22,10 +22,7 @@ public struct ContextService {
self.mastodonAPIClient = mastodonAPIClient
self.contentDatabase = contentDatabase
sections = contentDatabase.contextObservation(parentID: statusID)
navigationService = NavigationService(
status: nil,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase)
navigationService = NavigationService(mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
}
}

View file

@ -15,14 +15,14 @@ public enum Navigation {
}
public struct NavigationService {
private let status: Status?
private let mastodonAPIClient: MastodonAPIClient
private let contentDatabase: ContentDatabase
private let status: Status?
init(status: Status?, mastodonAPIClient: MastodonAPIClient, contentDatabase: ContentDatabase) {
self.status = status
init(mastodonAPIClient: MastodonAPIClient, contentDatabase: ContentDatabase, status: Status? = nil) {
self.mastodonAPIClient = mastodonAPIClient
self.contentDatabase = contentDatabase
self.status = status
}
}

View file

@ -15,9 +15,9 @@ public struct StatusService {
init(status: Status, mastodonAPIClient: MastodonAPIClient, contentDatabase: ContentDatabase) {
self.status = status
self.navigationService = NavigationService(
status: status.displayStatus,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase)
contentDatabase: contentDatabase,
status: status.displayStatus)
self.mastodonAPIClient = mastodonAPIClient
self.contentDatabase = contentDatabase
}

View file

@ -23,10 +23,7 @@ public struct TimelineService {
self.mastodonAPIClient = mastodonAPIClient
self.contentDatabase = contentDatabase
sections = contentDatabase.observation(timeline: timeline)
navigationService = NavigationService(
status: nil,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase)
navigationService = NavigationService(mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
nextPageMaxIDs = nextPageMaxIDsSubject.eraseToAnyPublisher()
if case let .tag(tag) = timeline {