Don't allow Twitter or Reddit feeds to be added to accounts that can't handle them

This commit is contained in:
Maurice Parker
2020-08-11 20:19:17 -05:00
parent c4ad7c71fd
commit f8cf5676e9
4 changed files with 10 additions and 5 deletions

View File

@@ -405,6 +405,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
}
let isDisplayingSheet = mainWindowController?.isDisplayingSheet ?? false
let isSpecialAccountAvailable = AccountManager.shared.activeAccounts.contains(where: { $0.type == .onMyMac || $0.type == .cloudKit })
if item.action == #selector(refreshAll(_:)) {
return !AccountManager.shared.refreshInProgress && !AccountManager.shared.activeAccounts.isEmpty
@@ -419,13 +420,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
return !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty
}
if item.action == #selector(showAddRedditFeedWindow(_:)) {
guard !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty else {
guard !isDisplayingSheet && isSpecialAccountAvailable else {
return false
}
return ExtensionPointManager.shared.isRedditEnabled
}
if item.action == #selector(showAddTwitterFeedWindow(_:)) {
guard !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty else {
guard !isDisplayingSheet && isSpecialAccountAvailable else {
return false
}
return ExtensionPointManager.shared.isTwitterEnabled

View File

@@ -71,7 +71,7 @@ class AddTwitterFeedWindowController : NSWindowController, AddFeedWindowControll
}
accountPopupButton.menu = accountMenu
folderPopupButton.menu = FolderTreeMenu.createFolderPopupMenu(with: folderTreeController.rootNode)
folderPopupButton.menu = FolderTreeMenu.createFolderPopupMenu(with: folderTreeController.rootNode, restrictToSpecialAccounts: true)
if let container = AddWebFeedDefaultContainer.defaultContainer {
if let folder = container as? Folder, let account = folder.account {

View File

@@ -13,7 +13,7 @@ import Account
class FolderTreeMenu {
static func createFolderPopupMenu(with rootNode: Node) -> NSMenu {
static func createFolderPopupMenu(with rootNode: Node, restrictToSpecialAccounts: Bool = false) -> NSMenu {
let menu = NSMenu(title: "Folders")
menu.autoenablesItems = false
@@ -24,6 +24,10 @@ class FolderTreeMenu {
continue
}
if restrictToSpecialAccounts && !(account.type == .onMyMac || account.type == .cloudKit) {
continue
}
let menuItem = NSMenuItem(title: account.nameForDisplay, action: nil, keyEquivalent: "")
menuItem.representedObject = childNode.representedObject

View File

@@ -90,7 +90,7 @@ class AddRedditFeedWindowController : NSWindowController, AddFeedWindowControlle
}
accountPopupButton.menu = accountMenu
folderPopupButton.menu = FolderTreeMenu.createFolderPopupMenu(with: folderTreeController.rootNode)
folderPopupButton.menu = FolderTreeMenu.createFolderPopupMenu(with: folderTreeController.rootNode, restrictToSpecialAccounts: true)
if let container = AddWebFeedDefaultContainer.defaultContainer {
if let folder = container as? Folder, let account = folder.account {