From b1e6cffd09e125e9d86a7c0d5eaf728037f28268 Mon Sep 17 00:00:00 2001 From: Brandon Evans Date: Fri, 1 Jan 2021 11:45:55 -0700 Subject: [PATCH] Use helper from Current --- Xcodes/Backend/AppState.swift | 5 ++--- Xcodes/Backend/Environment.swift | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Xcodes/Backend/AppState.swift b/Xcodes/Backend/AppState.swift index 4e4c1fc..4dfa58d 100644 --- a/Xcodes/Backend/AppState.swift +++ b/Xcodes/Backend/AppState.swift @@ -9,7 +9,6 @@ import Version class AppState: ObservableObject { private let client = AppleAPI.Client() - private let helperClient = HelperClient() private var cancellables = Set() 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 diff --git a/Xcodes/Backend/Environment.swift b/Xcodes/Backend/Environment.swift index 203c5f4..512ad67 100644 --- a/Xcodes/Backend/Environment.swift +++ b/Xcodes/Backend/Environment.swift @@ -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 = helperClient.checkIfLatestHelperIsInstalled + var getVersion: () -> AnyPublisher = helperClient.getVersion + var switchXcodePath: (_ absolutePath: String) -> AnyPublisher = helperClient.switchXcodePath +}