From 759858118597f54d16e0e23493c0a5b5087be391 Mon Sep 17 00:00:00 2001 From: Ivan Grachyov Date: Fri, 30 Jul 2021 01:39:31 +0300 Subject: [PATCH] Delay initial input link processing until app did finish launching --- Encrypted Ink/AppDelegate.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Encrypted Ink/AppDelegate.swift b/Encrypted Ink/AppDelegate.swift index 1c2e0359..dec1818f 100644 --- a/Encrypted Ink/AppDelegate.swift +++ b/Encrypted Ink/AppDelegate.swift @@ -10,6 +10,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { private let priceService = PriceService.shared private let networkMonitor = NetworkMonitor.shared + private var didFinishLaunching = false + private var initialInputLink: String? + override init() { super.init() let manager = NSAppleEventManager.shared() @@ -31,6 +34,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { gasService.start() priceService.start() networkMonitor.start() + + didFinishLaunching = true + if let link = initialInputLink { + initialInputLink = nil + agent.processInputLink(link) + } } func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { @@ -46,7 +55,11 @@ class AppDelegate: NSObject, NSApplicationDelegate { private func processInput(url: String?, prefix: String) { if let url = url, url.hasPrefix(prefix), let link = url.dropFirst(prefix.count).removingPercentEncoding { - agent.processInputLink(link) + if didFinishLaunching { + agent.processInputLink(link) + } else { + initialInputLink = link + } } }