Updater improvements.

This commit is contained in:
Max Goedjen 2020-09-18 14:05:42 -07:00
parent 5601d7eab8
commit 435a22754c
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
3 changed files with 15 additions and 13 deletions

View File

@ -11,8 +11,11 @@ public class Updater: ObservableObject, UpdaterProtocol {
@Published public var update: Release? @Published public var update: Release?
public init() { public init(hasRunSetup: Bool) {
checkForUpdates() if hasRunSetup {
// Don't do a launch check if the user hasn't seen the setup prompt explaining updater yet.
checkForUpdates()
}
let timer = Timer.scheduledTimer(withTimeInterval: 60*60*24, repeats: true) { _ in let timer = Timer.scheduledTimer(withTimeInterval: 60*60*24, repeats: true) { _ in
self.checkForUpdates() self.checkForUpdates()
} }

View File

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

View File

@ -6,15 +6,14 @@ import Brief
@main @main
struct AppDelegate: App { struct AppDelegate: App {
let storeList: SecretStoreList = { private let storeList: SecretStoreList = {
let list = SecretStoreList() let list = SecretStoreList()
list.add(store: SecureEnclave.Store()) list.add(store: SecureEnclave.Store())
list.add(store: SmartCard.Store()) list.add(store: SmartCard.Store())
return list return list
}() }()
let updater = Updater() private let agentStatusChecker = AgentStatusChecker()
let agentStatusChecker = AgentStatusChecker() private let justUpdatedChecker = JustUpdatedChecker()
let justUpdatedChecker = JustUpdatedChecker()
@State private var showingSetup = false @State private var showingSetup = false
@State private var showingCreation = false @State private var showingCreation = false
@ -24,7 +23,7 @@ struct AppDelegate: App {
WindowGroup { WindowGroup {
ContentView<Updater, AgentStatusChecker>(showingCreation: $showingCreation, runningSetup: $showingSetup) ContentView<Updater, AgentStatusChecker>(showingCreation: $showingCreation, runningSetup: $showingSetup)
.environmentObject(storeList) .environmentObject(storeList)
.environmentObject(updater) .environmentObject(Updater(hasRunSetup: hasRunSetup))
.environmentObject(agentStatusChecker) .environmentObject(agentStatusChecker)
.sheet(isPresented: $showingSetup) { .sheet(isPresented: $showingSetup) {
SetupView { completed in SetupView { completed in
@ -48,7 +47,7 @@ struct AppDelegate: App {
Button("New Secret") { Button("New Secret") {
showingCreation = true showingCreation = true
} }
.keyboardShortcut(KeyboardShortcut(KeyEquivalent("N"), modifiers: .command)) .keyboardShortcut(KeyboardShortcut(KeyEquivalent("N"), modifiers: [.command, .shift]))
} }
CommandGroup(replacing: .help) { CommandGroup(replacing: .help) {
Button("Help") { Button("Help") {