diff --git a/Sesame-Watch Watch App/UnlockView.swift b/Sesame-Watch Watch App/UnlockView.swift index f437ef7..82c46ca 100644 --- a/Sesame-Watch Watch App/UnlockView.swift +++ b/Sesame-Watch Watch App/UnlockView.swift @@ -41,7 +41,7 @@ struct ContentView: View { .aspectRatio(contentMode: .fit) .fontWeight(.ultraLight) .padding() - .onTapGesture { unlock(quit: true) } + .onTapGesture { coordinator.startUnlock() } if coordinator.isPerformingRequest { ProgressView() .progressViewStyle(CircularProgressViewStyle()) @@ -59,14 +59,10 @@ struct ContentView: View { guard launched else { return } - unlock(quit: true) + coordinator.startUnlock(quitAfterSuccess: true) didLaunchFromComplication = false } } - - private func unlock(quit: Bool) { - coordinator.startUnlock(quitAfterSuccess: quit) - } } #Preview { diff --git a/Sesame/Common/RequestCoordinator.swift b/Sesame/Common/RequestCoordinator.swift index 6fa12c5..5f0de49 100644 --- a/Sesame/Common/RequestCoordinator.swift +++ b/Sesame/Common/RequestCoordinator.swift @@ -65,13 +65,16 @@ final class RequestCoordinator: ObservableObject { isPerformingRequest = true Task { let finalResult = await performFullChallengeResponse() - if finalResult == .unlocked, quitAfterSuccess { - exit(EXIT_SUCCESS) - } + DispatchQueue.main.async { self.state = finalResult self.isPerformingRequest = false } + if finalResult == .unlocked, quitAfterSuccess { + DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) { + exit(EXIT_SUCCESS) + } + } scheduleReturnToReadyState() } }