mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-12 20:47:22 +01:00
WIP
This commit is contained in:
@@ -7,8 +7,10 @@ import SmartCardSecretKit
|
||||
import SecretAgentKit
|
||||
import Brief
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct SecretiveApp: App {
|
||||
|
||||
private let storeList: SecretStoreList = {
|
||||
let list = SecretStoreList()
|
||||
@@ -29,19 +31,24 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
private var updateSink: AnyCancellable?
|
||||
private let logger = Logger(subsystem: "com.maxgoedjen.secretive.secretagent", category: "AppDelegate")
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
logger.debug("SecretAgent finished launching")
|
||||
DispatchQueue.main.async {
|
||||
self.socketController.handler = self.agent.handle(reader:writer:)
|
||||
}
|
||||
NotificationCenter.default.addObserver(forName: .secretStoreReloaded, object: nil, queue: .main) { [self] _ in
|
||||
try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true)
|
||||
}
|
||||
try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true)
|
||||
notifier.prompt()
|
||||
updateSink = updater.$update.sink { update in
|
||||
guard let update = update else { return }
|
||||
self.notifier.notify(update: update, ignore: self.updater.ignore(release:))
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
Text("Hello")
|
||||
.onAppear {
|
||||
// logger.debug("SecretAgent finished launching")
|
||||
// DispatchQueue.main.async {
|
||||
// self.socketController.handler = self.agent.handle(reader:writer:)
|
||||
// }
|
||||
// NotificationCenter.default.addObserver(forName: .secretStoreReloaded, object: nil, queue: .main) { [self] _ in
|
||||
// try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true)
|
||||
// }
|
||||
// try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true)
|
||||
// notifier.prompt()
|
||||
// updateSink = updater.$update.sink { update in
|
||||
// guard let update = update else { return }
|
||||
// self.notifier.notify(update: update, ignore: self.updater.ignore(release:))
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,42 +143,42 @@ extension Notifier {
|
||||
|
||||
}
|
||||
|
||||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
let category = response.notification.request.content.categoryIdentifier
|
||||
switch category {
|
||||
case Notifier.Constants.updateCategoryIdentitifier:
|
||||
handleUpdateResponse(response: response)
|
||||
case Notifier.Constants.persistAuthenticationCategoryIdentitifier:
|
||||
handlePersistAuthenticationResponse(response: response)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
completionHandler()
|
||||
}
|
||||
|
||||
func handleUpdateResponse(response: UNNotificationResponse) {
|
||||
guard let update = release else { return }
|
||||
switch response.actionIdentifier {
|
||||
case Notifier.Constants.updateActionIdentitifier, UNNotificationDefaultActionIdentifier:
|
||||
NSWorkspace.shared.open(update.html_url)
|
||||
case Notifier.Constants.ignoreActionIdentitifier:
|
||||
ignore?(update)
|
||||
default:
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
|
||||
func handlePersistAuthenticationResponse(response: UNNotificationResponse) {
|
||||
guard let secretID = response.notification.request.content.userInfo[Notifier.Constants.persistSecretIDKey] as? String, let secret = pendingPersistableSecrets[secretID],
|
||||
let storeID = response.notification.request.content.userInfo[Notifier.Constants.persistStoreIDKey] as? String, let store = pendingPersistableStores[storeID]
|
||||
else { return }
|
||||
pendingPersistableSecrets[secretID] = nil
|
||||
persistAuthentication?(secret, store, persistOptions[response.actionIdentifier])
|
||||
}
|
||||
|
||||
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
||||
completionHandler([.list, .banner])
|
||||
}
|
||||
// func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
// let category = response.notification.request.content.categoryIdentifier
|
||||
// switch category {
|
||||
// case Notifier.Constants.updateCategoryIdentitifier:
|
||||
// handleUpdateResponse(response: response)
|
||||
// case Notifier.Constants.persistAuthenticationCategoryIdentitifier:
|
||||
// handlePersistAuthenticationResponse(response: response)
|
||||
// default:
|
||||
// break
|
||||
// }
|
||||
//
|
||||
// completionHandler()
|
||||
// }
|
||||
//
|
||||
// func handleUpdateResponse(response: UNNotificationResponse) {
|
||||
// guard let update = release else { return }
|
||||
// switch response.actionIdentifier {
|
||||
// case Notifier.Constants.updateActionIdentitifier, UNNotificationDefaultActionIdentifier:
|
||||
// NSWorkspace.shared.open(update.html_url)
|
||||
// case Notifier.Constants.ignoreActionIdentitifier:
|
||||
// ignore?(update)
|
||||
// default:
|
||||
// fatalError()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// func handlePersistAuthenticationResponse(response: UNNotificationResponse) {
|
||||
// guard let secretID = response.notification.request.content.userInfo[Notifier.Constants.persistSecretIDKey] as? String, let secret = pendingPersistableSecrets[secretID],
|
||||
// let storeID = response.notification.request.content.userInfo[Notifier.Constants.persistStoreIDKey] as? String, let store = pendingPersistableStores[storeID]
|
||||
// else { return }
|
||||
// pendingPersistableSecrets[secretID] = nil
|
||||
// persistAuthentication?(secret, store, persistOptions[response.actionIdentifier])
|
||||
// }
|
||||
//
|
||||
// func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
||||
// completionHandler([.list, .banner])
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user