From 0d36b276e94adfb868b59529f4f8e98936f20a87 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 18 Oct 2020 20:32:10 -0500 Subject: [PATCH] Disable the Import Subscriptions menu item if there aren't any accounts that can import OPML files. --- Mac/AppDelegate.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index 713480a8f..949492b40 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -418,32 +418,43 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, if item.action == #selector(refreshAll(_:)) { return !AccountManager.shared.refreshInProgress && !AccountManager.shared.activeAccounts.isEmpty } + + if item.action == #selector(importOPMLFromFile(_:)) { + return AccountManager.shared.activeAccounts.contains(where: { !$0.behaviors.contains(where: { $0 == .disallowOPMLImports }) }) + } + if item.action == #selector(addAppNews(_:)) { return !isDisplayingSheet && !AccountManager.shared.anyAccountHasFeedWithURL(appNewsURLString) && !AccountManager.shared.activeAccounts.isEmpty } + if item.action == #selector(sortByNewestArticleOnTop(_:)) || item.action == #selector(sortByOldestArticleOnTop(_:)) { return mainWindowController?.isOpen ?? false } + if item.action == #selector(showAddWebFeedWindow(_:)) || item.action == #selector(showAddFolderWindow(_:)) { return !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty } + if item.action == #selector(showAddRedditFeedWindow(_:)) { guard !isDisplayingSheet && isSpecialAccountAvailable && ExtensionPointManager.shared.isRedditEnabled else { return false } return ExtensionPointManager.shared.isRedditEnabled } + if item.action == #selector(showAddTwitterFeedWindow(_:)) { guard !isDisplayingSheet && isSpecialAccountAvailable && ExtensionPointManager.shared.isTwitterEnabled else { return false } return ExtensionPointManager.shared.isTwitterEnabled } + #if !MAC_APP_STORE if item.action == #selector(toggleWebInspectorEnabled(_:)) { (item as! NSMenuItem).state = AppDefaults.shared.webInspectorEnabled ? .on : .off } #endif + return true }