1
0
spegling av https://github.com/maxgoedjen/secretive.git synced 2026-03-15 13:57:24 +01:00

Better processing.

This commit is contained in:
Max Goedjen
2020-11-11 16:16:44 -08:00
förälder 7de561af5d
incheckning 320dd49ce0

Visa fil

@@ -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
}
}