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