From d12e515a9c89a31990a2a38c2cd4297dffdca6dc Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Thu, 19 Dec 2024 11:22:22 +0100 Subject: [PATCH] feat: added check if 2 seconds elapsed since the app started before showing the main app window --- Stats/AppDelegate.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Stats/AppDelegate.swift b/Stats/AppDelegate.swift index 4c9f1c6b..f6b90f06 100755 --- a/Stats/AppDelegate.swift +++ b/Stats/AppDelegate.swift @@ -49,6 +49,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele Store.shared.bool(key: "pause", defaultValue: false) } + private var startTS: Date? + static func main() { let app = NSApplication.shared let delegate = AppDelegate() @@ -72,6 +74,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele NotificationCenter.default.addObserver(self, selector: #selector(listenForAppPause), name: .pause, object: nil) info("Stats started in \((startingPoint.timeIntervalSinceNow * -1).rounded(toPlaces: 4)) seconds") + self.startTS = Date() } func applicationWillTerminate(_ aNotification: Notification) { @@ -87,6 +90,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele self.clickInNotification = false return true } + guard let startTS = self.startTS, Date().timeIntervalSince(startTS) > 2 else { return false } if flag { self.settingsWindow.makeKeyAndOrderFront(self)