Add restart

This commit is contained in:
Max Goedjen
2022-12-22 18:33:05 -05:00
parent 8679ca3da0
commit 9fc7d2548e
4 changed files with 12 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import SecretKit
protocol AgentStatusCheckerProtocol: ObservableObject {
var running: Bool { get }
var developmentBuild: Bool { get }
func restart()
}
class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {
@@ -37,12 +38,15 @@ class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {
return nil
}
// Whether Secretive is being run in an Xcode environment.
var developmentBuild: Bool {
Bundle.main.bundleURL.absoluteString.contains("/Library/Developer/Xcode")
}
func restart() {
instanceSecretAgentProcess?.forceTerminate()
}
}

View File

@@ -10,4 +10,7 @@ class PreviewAgentStatusChecker: AgentStatusCheckerProtocol {
self.running = running
}
func restart() {
}
}

View File

@@ -149,6 +149,9 @@ extension ContentView {
.padding(5)
Text("SecretAgent is a process that runs in the background to sign requests, so you don't need to keep Secretive open all the time.\n\n**You can close Secretive, and everything will still keep working.**")
.frame(width: 300)
Button("Restart Agent") {
self.agentStatusChecker.restart()
}
}
.padding()
}