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)] } .map { [$0.map(CollectionItem.account)] }
.eraseToAnyPublisher() .eraseToAnyPublisher()
nextPageMaxIDs = nextPageMaxIDsSubject.eraseToAnyPublisher() nextPageMaxIDs = nextPageMaxIDsSubject.eraseToAnyPublisher()
navigationService = NavigationService( navigationService = NavigationService(mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
status: nil,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase)
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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