Set the menu item state for the sort-by menu items.

This commit is contained in:
Brent Simmons 2018-01-27 15:24:33 -08:00
parent 8968d00d6d
commit 6e63ce5968

View File

@ -132,11 +132,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
authorAvatarDownloader = AuthorAvatarDownloader(imageDownloader: imageDownloader)
feedIconDownloader = FeedIconDownloader(imageDownloader: imageDownloader)
updateSortMenuItems()
createAndShowMainWindow()
NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(AppDelegate.getURL(_:_:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
NotificationCenter.default.addObserver(self, selector: #selector(feedSettingDidChange(_:)), name: .FeedSettingDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
DispatchQueue.main.async {
self.unreadCount = AccountManager.shared.unreadCount
@ -221,6 +223,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
inspectorWindowController.objects = objectsForInspector()
}
@objc func userDefaultsDidChange(_ note: Notification) {
updateSortMenuItems()
}
// MARK: Main Window
func windowControllerWithName(_ storyboardName: String) -> NSWindowController {
@ -498,4 +505,11 @@ private extension AppDelegate {
inspectorWindowController.saveState()
}
}
func updateSortMenuItems() {
let sortByNewestOnTop = AppDefaults.shared.timelineSortDirection == .orderedDescending
sortByNewestArticleOnTopMenuItem.state = sortByNewestOnTop ? .on : .off
sortByOldestArticleOnTopMenuItem.state = sortByNewestOnTop ? .off : .on
}
}