Skip to content

Commit

Permalink
feat: added check if 2 seconds elapsed since the app started before s…
Browse files Browse the repository at this point in the history
…howing the main app window
  • Loading branch information
exelban committed Dec 19, 2024
1 parent e103111 commit d12e515
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Stats/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit d12e515

Please sign in to comment.