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 17:33:48 -05:00
parent 0835e789e5
commit c4ad7c71fd
3 changed files with 16 additions and 3 deletions

View File

@ -17,6 +17,7 @@ protocol AddFeedFolderViewControllerDelegate {
class AddFeedFolderViewController: UITableViewController {
var delegate: AddFeedFolderViewControllerDelegate?
var addFeedType = AddFeedType.web
var initialContainer: Container?
var containers = [Container]()
@ -24,7 +25,14 @@ class AddFeedFolderViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
for account in AccountManager.shared.sortedActiveAccounts {
var sortedActiveAccounts: [Account]
if addFeedType == .web {
sortedActiveAccounts = AccountManager.shared.sortedActiveAccounts
} else {
sortedActiveAccounts = AccountManager.shared.sortedActiveAccounts.filter { $0.type == .onMyMac || $0.type == .cloudKit }
}
for account in sortedActiveAccounts {
containers.append(account)
if let sortedFolders = account.sortedFolders {
containers.append(contentsOf: sortedFolders)

View File

@ -164,6 +164,7 @@ class AddFeedViewController: UITableViewController {
navController.modalPresentationStyle = .currentContext
let folderViewController = navController.topViewController as! AddFeedFolderViewController
folderViewController.delegate = self
folderViewController.addFeedType = addFeedType
folderViewController.initialContainer = container
present(navController, animated: true)
}

View File

@ -421,8 +421,12 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
}
alertController.addAction(addWebFeedAction)
alertController.addAction(addRedditFeedAction)
alertController.addAction(addTwitterFeedAction)
if AccountManager.shared.activeAccounts.contains(where: { $0.type == .onMyMac || $0.type == .cloudKit }) {
alertController.addAction(addRedditFeedAction)
alertController.addAction(addTwitterFeedAction)
}
alertController.addAction(addWebFolderAction)
alertController.addAction(cancelAction)