Update for Big Sur & SwiftUI 2 (#128)

This commit is contained in:
Max Goedjen
2020-09-21 23:12:50 -07:00
committed by GitHub
parent 4cc312d4fa
commit 331e4ed0d6
39 changed files with 1021 additions and 701 deletions

View File

@@ -8,18 +8,18 @@ import Brief
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
let storeList: SecretStoreList = {
private let storeList: SecretStoreList = {
let list = SecretStoreList()
list.add(store: SecureEnclave.Store())
list.add(store: SmartCard.Store())
return list
}()
let updater = Updater()
let notifier = Notifier()
lazy var agent: Agent = {
private let updater = Updater(checkOnLaunch: false)
private let notifier = Notifier()
private lazy var agent: Agent = {
Agent(storeList: storeList, witness: notifier)
}()
lazy var socketController: SocketController = {
private lazy var socketController: SocketController = {
let path = (NSHomeDirectory() as NSString).appendingPathComponent("socket.ssh") as String
return SocketController(path: path)
}()

View File

@@ -13,15 +13,14 @@ class Notifier {
let updateAction = UNNotificationAction(identifier: Constants.updateActionIdentitifier, title: "Update", options: [])
let ignoreAction = UNNotificationAction(identifier: Constants.ignoreActionIdentitifier, title: "Ignore", options: [])
let updateCategory = UNNotificationCategory(identifier: Constants.updateCategoryIdentitifier, actions: [updateAction, ignoreAction], intentIdentifiers: [], options: [])
let criticalUpdateCategory = UNNotificationCategory(identifier: Constants.updateCategoryIdentitifier, actions: [updateAction], intentIdentifiers: [], options: [])
let criticalUpdateCategory = UNNotificationCategory(identifier: Constants.criticalUpdateCategoryIdentitifier, actions: [updateAction], intentIdentifiers: [], options: [])
UNUserNotificationCenter.current().setNotificationCategories([updateCategory, criticalUpdateCategory])
UNUserNotificationCenter.current().delegate = notificationDelegate
}
func prompt() {
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.requestAuthorization(options: .alert) { _, _ in
}
notificationCenter.requestAuthorization(options: .alert) { _, _ in }
}
func notify(accessTo secret: AnySecret, by provenance: SigningRequestProvenance) {
@@ -117,7 +116,7 @@ class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
completionHandler([.list, .banner])
}
}