From a37bfd5d749615432b3432830c98fb935da03cdb Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 7 May 2020 10:03:04 -0400 Subject: [PATCH] Adds an account behavior to disable folders Some sync services (Feed Wrangler) don't support folders. This behavior removes the account from the UI when adding new folders. --- Frameworks/Account/AccountBehaviors.swift | 5 +++++ .../Account/FeedWrangler/FeedWranglerAccountDelegate.swift | 2 +- Mac/MainWindow/AddFolder/AddFolderWindowController.swift | 6 +++++- iOS/Add/AddFolderViewController.swift | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Frameworks/Account/AccountBehaviors.swift b/Frameworks/Account/AccountBehaviors.swift index 83b8aae9b..90776cdd3 100644 --- a/Frameworks/Account/AccountBehaviors.swift +++ b/Frameworks/Account/AccountBehaviors.swift @@ -28,6 +28,11 @@ public enum AccountBehavior: Equatable { */ case disallowFeedInRootFolder + /** + Account doesn't support folders + */ + case disallowFolderManagement + /** Account doesn't support OPML imports */ diff --git a/Frameworks/Account/FeedWrangler/FeedWranglerAccountDelegate.swift b/Frameworks/Account/FeedWrangler/FeedWranglerAccountDelegate.swift index 7876f4ceb..5790cb008 100644 --- a/Frameworks/Account/FeedWrangler/FeedWranglerAccountDelegate.swift +++ b/Frameworks/Account/FeedWrangler/FeedWranglerAccountDelegate.swift @@ -16,7 +16,7 @@ import Secrets final class FeedWranglerAccountDelegate: AccountDelegate { - var behaviors: AccountBehaviors = [] + var behaviors: AccountBehaviors = [.disallowFolderManagement] var isOPMLImportInProgress = false var server: String? = FeedWranglerConfig.clientPath diff --git a/Mac/MainWindow/AddFolder/AddFolderWindowController.swift b/Mac/MainWindow/AddFolder/AddFolderWindowController.swift index 3dbb0abf7..209f03933 100644 --- a/Mac/MainWindow/AddFolder/AddFolderWindowController.swift +++ b/Mac/MainWindow/AddFolder/AddFolderWindowController.swift @@ -42,7 +42,11 @@ class AddFolderWindowController : NSWindowController { let menu = NSMenu() accountPopupButton.menu = menu - for oneAccount in AccountManager.shared.sortedActiveAccounts { + let accounts = AccountManager.shared + .sortedActiveAccounts + .filter { !$0.behaviors.contains(.disallowFolderManagement) } + + for oneAccount in accounts { let oneMenuItem = NSMenuItem() oneMenuItem.title = oneAccount.nameForDisplay diff --git a/iOS/Add/AddFolderViewController.swift b/iOS/Add/AddFolderViewController.swift index 26d794a10..1500d84b8 100644 --- a/iOS/Add/AddFolderViewController.swift +++ b/iOS/Add/AddFolderViewController.swift @@ -43,7 +43,9 @@ class AddFolderViewController: UITableViewController, AddContainerViewController super.viewDidLoad() - accounts = AccountManager.shared.sortedActiveAccounts + accounts = AccountManager.shared + .sortedActiveAccounts + .filter { !$0.behaviors.contains(.disallowFolderManagement) } nameTextField.delegate = self