Browse Source

Allocation optimizations..

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
a6332241a3
  1. 16
      Clocker/AppDelegate.swift

16
Clocker/AppDelegate.swift

@ -45,9 +45,6 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
}
public func applicationDidFinishLaunching(_: Notification) {
// Initializing the event store takes really long
EventCenter.sharedCenter()
// Required for migrating our model type to CoreModelKit
NSKeyedUnarchiver.setClass(CoreModelKit.TimezoneData.classForKeyedUnarchiver(), forClassName: "Clocker.TimezoneData")
@ -125,10 +122,6 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
assignShortcut()
panelObserver = panelController.observe(\.hasActivePanel, options: [.new]) { obj, _ in
self.statusBarHandler.setHasActiveIcon(obj.hasActivePanelGetter())
}
let defaults = UserDefaults.standard
setActivationPolicy()
@ -246,6 +239,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
// No need to call NSApp.activate here since `showFloatingWindow` takes care of this
showFloatingWindow()
} else {
setupPanelObserverIfNeeeded()
panelController.showWindow(nil)
panelController.setActivePanel(newValue: !panelController.hasActivePanelGetter())
NSApp.activate(ignoringOtherApps: true)
@ -267,4 +261,12 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
open func invalidateMenubarTimer(_ showIcon: Bool) {
statusBarHandler.invalidateTimer(showIcon: showIcon, isSyncing: true)
}
private func setupPanelObserverIfNeeeded() {
if panelObserver == nil {
panelObserver = panelController.observe(\.hasActivePanel, options: [.new]) { obj, _ in
self.statusBarHandler.setHasActiveIcon(obj.hasActivePanelGetter())
}
}
}
}

Loading…
Cancel
Save