mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Don't allow Twitter or Reddit feeds to be added to accounts that can't handle them
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user