Use helper from Current

This commit is contained in:
Brandon Evans 2021-01-01 11:45:55 -07:00
parent 2052ff54ff
commit b1e6cffd09
No known key found for this signature in database
GPG key ID: D58A4B8DB64F8E93
2 changed files with 11 additions and 3 deletions

View file

@ -9,7 +9,6 @@ import Version
class AppState: ObservableObject {
private let client = AppleAPI.Client()
private let helperClient = HelperClient()
private var cancellables = Set<AnyCancellable>()
private var selectPublisher: AnyCancellable?
private var uninstallPublisher: AnyCancellable?
@ -184,14 +183,14 @@ class AppState: ObservableObject {
// MARK: - Helper
func installHelper() {
HelperInstaller.install()
Current.helper.install()
checkIfHelperIsInstalled()
}
private func checkIfHelperIsInstalled() {
helperInstallState = .unknown
helperClient.checkIfLatestHelperIsInstalled()
Current.helper.checkIfLatestHelperIsInstalled()
.receive(on: DispatchQueue.main)
.sink(
receiveValue: { installed in

View file

@ -19,6 +19,7 @@ public struct Environment {
public var keychain = Keychain()
public var defaults = Defaults()
public var date: () -> Date = Date.init
public var helper = Helper()
}
public var Current = Environment()
@ -152,3 +153,11 @@ public struct Defaults {
removeObject(key)
}
}
private let helperClient = HelperClient()
public struct Helper {
var install: () -> Void = HelperInstaller.install
var checkIfLatestHelperIsInstalled: () -> AnyPublisher<Bool, Never> = helperClient.checkIfLatestHelperIsInstalled
var getVersion: () -> AnyPublisher<String, Error> = helperClient.getVersion
var switchXcodePath: (_ absolutePath: String) -> AnyPublisher<Void, Error> = helperClient.switchXcodePath
}