Add settings for batch auth handling. (#870)

This commit is contained in:
Max Goedjen authored and GitHub committed 2026-11-17 07:15:56 +00:00
1 parent 164aacc94e
commit 56c2f841ed
10 files changed
+191 -20

No files matched your search

+11 -1
View File
@@ -9,6 +9,7 @@ import Observation
import Common
import SwiftUI
import CertificateKit
import SettingsKit
@main
struct SecretAgent: App {
@@ -26,7 +27,7 @@ struct SecretAgent: App {
private let updater = Updater(checkOnLaunch: true)
private let notifier = Notifier()
private let authenticationHandler = AuthenticationHandler()
private let authenticationHandler = AuthenticationHandler(settingsStore: EnvironmentValues._settingsStore)
private let publicKeyFileStoreController = PublicKeyFileStoreController(publicKeysURL: URL.publicKeyDirectory, certificatesURL: URL.certificatesDirectory)
@Environment(\.openWindow) var openWindow
@@ -117,3 +118,12 @@ struct SecretAgent: App {
}
struct PendingRequestsViewIdentifier: Codable, Hashable {}
extension EnvironmentValues {
@MainActor fileprivate static let _settingsStore = SettingsStore()
@MainActor var settingsStore: SettingsStore {
EnvironmentValues._settingsStore
}
}
@@ -3,11 +3,14 @@ import SecretKit
import SecretAgentKit
import SmartCardSecretKit
import Common
import ApplicationServices
import SettingsKit
struct PendingRequestsView: View {
private let authenticationHandler: any AuthenticationHandlerProtocol
@Environment(\.dismissWindow) var dismiss
@Environment(\.settingsStore) var settingsStore
init(authenticationHandler: some AuthenticationHandlerProtocol) {
self.authenticationHandler = authenticationHandler
@@ -92,6 +95,19 @@ struct PendingRequestsView: View {
}
}
.safeAreaPadding(20)
.onAppear {
guard settingsStore.showDockItemWithPendingRequestsScreen else { return }
var process = ProcessSerialNumber(highLongOfPSN: 0, lowLongOfPSN: UInt32(kCurrentProcess))
unsafe TransformProcessType(&process, ProcessApplicationTransformState(kProcessTransformToForegroundApplication))
NSApplication.shared.dockTile.showsApplicationBadge = true
NSApplication.shared.dockTile.display()
NSApplication.shared.requestUserAttention(.criticalRequest)
}
.onDisappear {
guard settingsStore.showDockItemWithPendingRequestsScreen else { return }
var process = ProcessSerialNumber(highLongOfPSN: 0, lowLongOfPSN: UInt32(kCurrentProcess))
unsafe TransformProcessType(&process, ProcessApplicationTransformState(kProcessTransformToBackgroundApplication))
}
}
}