From d6ed0155145f0100eb580a40dafc187d4ee32f56 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 12 Aug 2020 10:27:58 -0500 Subject: [PATCH] Don't allow users to add Reddit or Twitter feeds if they don't have an extension configured. --- Mac/AppDelegate.swift | 4 ++-- .../ExtensionPoints/ExtensionPointAddViewController.swift | 2 +- iOS/MasterFeed/MasterFeedViewController.swift | 8 ++++++-- iOS/Settings/AddExtensionPointViewController.swift | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index 335ab4617..c490ffdde 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -420,13 +420,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, return !isDisplayingSheet && !AccountManager.shared.activeAccounts.isEmpty } if item.action == #selector(showAddRedditFeedWindow(_:)) { - guard !isDisplayingSheet && isSpecialAccountAvailable else { + guard !isDisplayingSheet && isSpecialAccountAvailable && ExtensionPointManager.shared.isRedditEnabled else { return false } return ExtensionPointManager.shared.isRedditEnabled } if item.action == #selector(showAddTwitterFeedWindow(_:)) { - guard !isDisplayingSheet && isSpecialAccountAvailable else { + guard !isDisplayingSheet && isSpecialAccountAvailable && ExtensionPointManager.shared.isTwitterEnabled else { return false } return ExtensionPointManager.shared.isTwitterEnabled diff --git a/Mac/Preferences/ExtensionPoints/ExtensionPointAddViewController.swift b/Mac/Preferences/ExtensionPoints/ExtensionPointAddViewController.swift index d1c9f70e6..7163fca0a 100644 --- a/Mac/Preferences/ExtensionPoints/ExtensionPointAddViewController.swift +++ b/Mac/Preferences/ExtensionPoints/ExtensionPointAddViewController.swift @@ -27,7 +27,7 @@ class ExtensionPointAddViewController: NSViewController { super.viewDidLoad() tableView.dataSource = self tableView.delegate = self - availableExtensionPointTypes = ExtensionPointManager.shared.availableExtensionPointTypes + availableExtensionPointTypes = ExtensionPointManager.shared.availableExtensionPointTypes.sorted(by: { $0.title < $1.title }) } } diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 897755b6e..e5f923085 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -423,8 +423,12 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { alertController.addAction(addWebFeedAction) if AccountManager.shared.activeAccounts.contains(where: { $0.type == .onMyMac || $0.type == .cloudKit }) { - alertController.addAction(addRedditFeedAction) - alertController.addAction(addTwitterFeedAction) + if ExtensionPointManager.shared.isRedditEnabled { + alertController.addAction(addRedditFeedAction) + } + if ExtensionPointManager.shared.isTwitterEnabled { + alertController.addAction(addTwitterFeedAction) + } } alertController.addAction(addWebFolderAction) diff --git a/iOS/Settings/AddExtensionPointViewController.swift b/iOS/Settings/AddExtensionPointViewController.swift index a9b44fce0..07b923922 100644 --- a/iOS/Settings/AddExtensionPointViewController.swift +++ b/iOS/Settings/AddExtensionPointViewController.swift @@ -18,7 +18,7 @@ class AddExtensionPointViewController: UITableViewController, AddExtensionPointD override func viewDidLoad() { super.viewDidLoad() - availableExtensionPointTypes = ExtensionPointManager.shared.availableExtensionPointTypes + availableExtensionPointTypes = ExtensionPointManager.shared.availableExtensionPointTypes.sorted(by: { $0.title < $1.title }) } override func numberOfSections(in tableView: UITableView) -> Int {