Attempt to quit app when launched from complication
This commit is contained in:
@ -58,13 +58,16 @@ final class RequestCoordinator: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func startUnlock() {
|
||||
func startUnlock(quitAfterSuccess: Bool = false) {
|
||||
guard !isPerformingRequest else {
|
||||
return
|
||||
}
|
||||
isPerformingRequest = true
|
||||
Task {
|
||||
let finalResult = await performFullChallengeResponse()
|
||||
if finalResult == .unlocked, quitAfterSuccess {
|
||||
exit(EXIT_SUCCESS)
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
self.state = finalResult
|
||||
self.isPerformingRequest = false
|
||||
|
@ -40,9 +40,8 @@ struct ContentView: View {
|
||||
.background(.white.opacity(0.2))
|
||||
.cornerRadius(smallButtonSize / 2)
|
||||
.font(.title2)
|
||||
|
||||
}
|
||||
Button("Unlock", action: coordinator.startUnlock)
|
||||
Button("Unlock", action: unlock)
|
||||
.frame(width: unlockButtonSize, height: unlockButtonSize)
|
||||
.background(buttonBackground)
|
||||
.cornerRadius(unlockButtonSize / 2)
|
||||
@ -82,7 +81,9 @@ struct ContentView: View {
|
||||
.preferredColorScheme(.dark)
|
||||
}
|
||||
|
||||
|
||||
private func unlock() {
|
||||
coordinator.startUnlock()
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user