Trigger old, expired timers when the computer wakes from sleep to get refreshes going again. Issue #1122
This commit is contained in:
parent
42f97172b7
commit
66ce3db1fc
@ -71,6 +71,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(inspectableObjectsDidChange(_:)), name: .InspectableObjectsDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(inspectableObjectsDidChange(_:)), name: .InspectableObjectsDidChange, object: nil)
|
||||||
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(didWakeNotification(_:)), name: NSWorkspace.didWakeNotification, object: nil)
|
||||||
|
|
||||||
appDelegate = self
|
appDelegate = self
|
||||||
}
|
}
|
||||||
@ -223,10 +224,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func applicationDidBecomeActive(_ notification: Notification) {
|
func applicationDidBecomeActive(_ notification: Notification) {
|
||||||
// It’s possible there’s a refresh timer set to go off in the past.
|
fireOldTimers()
|
||||||
// In that case, refresh now and update the timer.
|
|
||||||
refreshTimer?.fireOldTimer()
|
|
||||||
syncTimer?.fireOldTimer()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationDidResignActive(_ notification: Notification) {
|
func applicationDidResignActive(_ notification: Notification) {
|
||||||
@ -283,6 +281,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
updateDockBadge()
|
updateDockBadge()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func didWakeNotification(_ note: Notification) {
|
||||||
|
fireOldTimers()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Main Window
|
// MARK: Main Window
|
||||||
|
|
||||||
func windowControllerWithName(_ storyboardName: String) -> NSWindowController {
|
func windowControllerWithName(_ storyboardName: String) -> NSWindowController {
|
||||||
@ -564,6 +566,13 @@ extension AppDelegate {
|
|||||||
|
|
||||||
private extension AppDelegate {
|
private extension AppDelegate {
|
||||||
|
|
||||||
|
func fireOldTimers() {
|
||||||
|
// It’s possible there’s a refresh timer set to go off in the past.
|
||||||
|
// In that case, refresh now and update the timer.
|
||||||
|
refreshTimer?.fireOldTimer()
|
||||||
|
syncTimer?.fireOldTimer()
|
||||||
|
}
|
||||||
|
|
||||||
func createReaderWindow() -> MainWindowController {
|
func createReaderWindow() -> MainWindowController {
|
||||||
|
|
||||||
return windowControllerWithName("MainWindow") as! MainWindowController
|
return windowControllerWithName("MainWindow") as! MainWindowController
|
||||||
|
Loading…
x
Reference in New Issue
Block a user