Add restart

This commit is contained in:
Max Goedjen 2022-12-22 18:33:05 -05:00
parent 8679ca3da0
commit 9fc7d2548e
No known key found for this signature in database
4 changed files with 12 additions and 2 deletions

View File

@ -266,7 +266,6 @@
isa = PBXGroup;
children = (
50617D8423FCE48E0099B055 /* ContentView.swift */,
5065E312295517C500E16645 /* ToolbarButtonStyle.swift */,
5079BA0E250F29BF00EA86F4 /* StoreListView.swift */,
50153E21250DECA300525160 /* SecretListItemView.swift */,
50C385A42407A76D00AF2719 /* SecretDetailView.swift */,
@ -278,6 +277,7 @@
50153E1F250AFCB200525160 /* UpdateView.swift */,
5066A6C12516F303004B5A36 /* SetupView.swift */,
5066A6C72516FE6E004B5A36 /* CopyableView.swift */,
5065E312295517C500E16645 /* ToolbarButtonStyle.swift */,
);
path = Views;
sourceTree = "<group>";

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()
}