Better processing.

This commit is contained in:
Max Goedjen 2020-11-11 16:16:44 -08:00
parent 7de561af5d
commit 320dd49ce0
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
1 changed files with 16 additions and 3 deletions

View File

@ -15,11 +15,24 @@ class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {
}
func check() {
running = secretAgentProcess != nil
running = instanceSecretAgentProcess != nil
}
var secretAgentProcess: NSRunningApplication? {
NSRunningApplication.runningApplications(withBundleIdentifier: Constants.secretAgentAppID).first
// All processes, including ones from older versions, etc
var secretAgentProcesses: [NSRunningApplication] {
NSRunningApplication.runningApplications(withBundleIdentifier: Constants.secretAgentAppID)
}
// The process corresponding to this instance of Secretive
var instanceSecretAgentProcess: NSRunningApplication? {
let agents = secretAgentProcesses
for agent in agents {
guard let url = agent.bundleURL else { continue }
if url.absoluteString.hasPrefix(Bundle.main.bundleURL.absoluteString) {
return agent
}
}
return nil
}
}