From 86578775e0d654e8a8045ebfdbadf8b2ac483df2 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 19 May 2019 10:21:42 -0500 Subject: [PATCH] Move menu validations to the app delegate. --- Mac/AppDelegate.swift | 2 +- Mac/MainWindow/MainWindowController.swift | 16 ---------------- .../Sidebar/SidebarViewController.swift | 8 -------- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index 81767442f..f39c94071 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -282,7 +282,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, return mainWindowController?.isOpen ?? false } if item.action == #selector(showAddFeedWindow(_:)) || item.action == #selector(showAddFolderWindow(_:)) { - return !isDisplayingSheet + return !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty } return true } diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index 7cb1edc7a..be1bc61dd 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -228,14 +228,6 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { return true } - if item.action == #selector(showAddFeedWindow(_:)) { - return canAddNewFeed() - } - - if item.action == #selector(showAddFolderWindow(_:)) { - return canAddNewFolder() - } - return true } @@ -600,14 +592,6 @@ private extension MainWindowController { return currentTimelineViewController?.canMarkAllAsRead() ?? false } - func canAddNewFeed() -> Bool { - return sidebarViewController?.canAddNewFeed() ?? false - } - - func canAddNewFolder() -> Bool { - return sidebarViewController?.canAddNewFolder() ?? false - } - func validateToggleRead(_ item: NSValidatedUserInterfaceItem) -> Bool { let validationStatus = currentTimelineViewController?.markReadCommandStatus() ?? .canDoNothing diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index 3489172df..5ce079b70 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -361,14 +361,6 @@ protocol SidebarDelegate: class { } - func canAddNewFeed() -> Bool { - return !accountNodes.isEmpty - } - - func canAddNewFolder() -> Bool { - return !accountNodes.isEmpty - } - } // MARK: - NSUserInterfaceValidations