mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added check if 2 seconds elapsed since the app started before showing the main app window
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user