From 435a22754c21887aa51fb156580a427cb316b16b Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Fri, 18 Sep 2020 14:05:42 -0700 Subject: [PATCH] Updater improvements. --- Brief/Updater.swift | 7 +++++-- SecretAgent/AppDelegate.swift | 10 +++++----- Secretive/App.swift | 11 +++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Brief/Updater.swift b/Brief/Updater.swift index a9b59a7..9153084 100644 --- a/Brief/Updater.swift +++ b/Brief/Updater.swift @@ -11,8 +11,11 @@ public class Updater: ObservableObject, UpdaterProtocol { @Published public var update: Release? - public init() { - checkForUpdates() + public init(hasRunSetup: Bool) { + 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 self.checkForUpdates() } diff --git a/SecretAgent/AppDelegate.swift b/SecretAgent/AppDelegate.swift index 6c8825b..305aa76 100644 --- a/SecretAgent/AppDelegate.swift +++ b/SecretAgent/AppDelegate.swift @@ -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(hasRunSetup: 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) }() diff --git a/Secretive/App.swift b/Secretive/App.swift index 5d64f4f..6489335 100644 --- a/Secretive/App.swift +++ b/Secretive/App.swift @@ -6,15 +6,14 @@ import Brief @main struct AppDelegate: App { - 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 agentStatusChecker = AgentStatusChecker() - let justUpdatedChecker = JustUpdatedChecker() + private let agentStatusChecker = AgentStatusChecker() + private let justUpdatedChecker = JustUpdatedChecker() @State private var showingSetup = false @State private var showingCreation = false @@ -24,7 +23,7 @@ struct AppDelegate: App { WindowGroup { ContentView(showingCreation: $showingCreation, runningSetup: $showingSetup) .environmentObject(storeList) - .environmentObject(updater) + .environmentObject(Updater(hasRunSetup: hasRunSetup)) .environmentObject(agentStatusChecker) .sheet(isPresented: $showingSetup) { SetupView { completed in @@ -48,7 +47,7 @@ struct AppDelegate: App { Button("New Secret") { showingCreation = true } - .keyboardShortcut(KeyboardShortcut(KeyEquivalent("N"), modifiers: .command)) + .keyboardShortcut(KeyboardShortcut(KeyEquivalent("N"), modifiers: [.command, .shift])) } CommandGroup(replacing: .help) { Button("Help") {