From a3ed59a78ca6fe4c29c287977b4d985e38eb980f Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Thu, 12 Nov 2020 21:17:07 -0800 Subject: [PATCH] Completion --- Secretive/App.swift | 5 +++-- Secretive/Controllers/LaunchAgentController.swift | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Secretive/App.swift b/Secretive/App.swift index f3e36f6..c26e9bf 100644 --- a/Secretive/App.swift +++ b/Secretive/App.swift @@ -40,8 +40,9 @@ struct Secretive: App { if hasRunSetup && !agentStatusChecker.running { // We've run setup, we didn't just update, launchd is just not doing it's thing. // Force a launch directly. - LaunchAgentController().forceLaunch() - agentStatusChecker.check() + LaunchAgentController().forceLaunch { _ in + agentStatusChecker.check() + } } } } diff --git a/Secretive/Controllers/LaunchAgentController.swift b/Secretive/Controllers/LaunchAgentController.swift index 9c000eb..80df05d 100644 --- a/Secretive/Controllers/LaunchAgentController.swift +++ b/Secretive/Controllers/LaunchAgentController.swift @@ -11,10 +11,11 @@ struct LaunchAgentController { return setEnabled(true) } - func forceLaunch() { + func forceLaunch(completion: ((Bool) -> Void)?) { Logger().debug("Agent is not running, attempting to force launch") let url = Bundle.main.bundleURL.appendingPathComponent("Contents/Library/LoginItems/SecretAgent.app") NSWorkspace.shared.openApplication(at: url, configuration: NSWorkspace.OpenConfiguration()) { app, error in + completion?(error == nil) if let error = error { Logger().error("Error force launching \(error.localizedDescription)") } else {