@@ -51,6 +51,10 @@ let appName = "NetNewsWire"
5151 @IBOutlet var sortByNewestArticleOnTopMenuItem : NSMenuItem !
5252 @IBOutlet var groupArticlesByFeedMenuItem : NSMenuItem !
5353 @IBOutlet var checkForUpdatesMenuItem : NSMenuItem !
54+ @IBOutlet var sortFeedsByNameMenuItem : NSMenuItem !
55+ @IBOutlet var sortFeedsByUnreadCountMenuItem : NSMenuItem !
56+ @IBOutlet var sortFeedsAscendingMenuItem : NSMenuItem !
57+ @IBOutlet var sortFeedsDescendingMenuItem : NSMenuItem !
5458
5559 var unreadCount = 0 {
5660 didSet {
@@ -174,6 +178,7 @@ let appName = "NetNewsWire"
174178
175179 updateSortMenuItems ( )
176180 updateGroupByFeedMenuItem ( )
181+ updateSortFeedsMenuItems ( )
177182
178183 if mainWindowController == nil {
179184 let mainWindowController = createAndShowMainWindow ( )
@@ -345,6 +350,7 @@ let appName = "NetNewsWire"
345350 func userDefaultsDidChange( ) {
346351 updateSortMenuItems ( )
347352 updateGroupByFeedMenuItem ( )
353+ updateSortFeedsMenuItems ( )
348354
349355 if lastRefreshInterval != AppDefaults . shared. refreshInterval {
350356 refreshTimer? . update ( )
@@ -439,6 +445,11 @@ let appName = "NetNewsWire"
439445 return mainWindowController? . isOpen ?? false
440446 }
441447
448+ if item. action == #selector( sortFeedsByName ( _: ) ) || item. action == #selector( sortFeedsByUnreadCount ( _: ) ) ||
449+ item. action == #selector( sortFeedsAscending ( _: ) ) || item. action == #selector( sortFeedsDescending ( _: ) ) {
450+ return mainWindowController? . isOpen ?? false
451+ }
452+
442453 if item. action == #selector( showAddFeedWindow ( _: ) ) || item. action == #selector( showAddFolderWindow ( _: ) ) {
443454 return !isDisplayingSheet && !AccountManager. shared. activeAccounts. isEmpty
444455 }
@@ -664,6 +675,22 @@ let appName = "NetNewsWire"
664675 AppDefaults . shared. timelineGroupByFeed. toggle ( )
665676 }
666677
678+ @IBAction func sortFeedsByName( _ sender: Any ? ) {
679+ AppDefaults . shared. sidebarSortType = . alphabetically
680+ }
681+
682+ @IBAction func sortFeedsByUnreadCount( _ sender: Any ? ) {
683+ AppDefaults . shared. sidebarSortType = . byUnreadCount
684+ }
685+
686+ @IBAction func sortFeedsAscending( _ sender: Any ? ) {
687+ AppDefaults . shared. sidebarSortAscending = true
688+ }
689+
690+ @IBAction func sortFeedsDescending( _ sender: Any ? ) {
691+ AppDefaults . shared. sidebarSortAscending = false
692+ }
693+
667694 @IBAction func checkForUpdates( _ sender: Any ? ) {
668695 softwareUpdater? . checkForUpdates ( )
669696 }
@@ -757,6 +784,16 @@ extension AppDelegate {
757784 sortByOldestArticleOnTopMenuItem. state = sortByNewestOnTop ? . off : . on
758785 }
759786
787+ @MainActor func updateSortFeedsMenuItems( ) {
788+ let sortType = AppDefaults . shared. sidebarSortType
789+ sortFeedsByNameMenuItem. state = sortType == . alphabetically ? . on : . off
790+ sortFeedsByUnreadCountMenuItem. state = sortType == . byUnreadCount ? . on : . off
791+
792+ let ascending = AppDefaults . shared. sidebarSortAscending
793+ sortFeedsAscendingMenuItem. state = ascending ? . on : . off
794+ sortFeedsDescendingMenuItem. state = ascending ? . off : . on
795+ }
796+
760797 @MainActor func updateGroupByFeedMenuItem( ) {
761798 let groupByFeedEnabled = AppDefaults . shared. timelineGroupByFeed
762799 groupArticlesByFeedMenuItem. state = groupByFeedEnabled ? . on : . off
0 commit comments