Hide the Add NetNewsWire feed option if already subscribed

This commit is contained in:
Maurice Parker
2019-10-21 18:02:44 -05:00
parent 3f974c7c2b
commit 67251da7ac
3 changed files with 13 additions and 11 deletions

View File

@@ -787,9 +787,11 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
func showSettings() {
let settingsNavController = UIStoryboard.settings.instantiateInitialViewController() as! UINavigationController
let settingsViewController = settingsNavController.topViewController as! SettingsViewController
settingsNavController.modalPresentationStyle = .formSheet
settingsNavController.preferredContentSize = SettingsViewController.preferredContentSizeForFormSheetDisplay
masterFeedViewController.present(settingsNavController, animated: true)
settingsViewController.presentingParentController = rootSplitViewController
rootSplitViewController.present(settingsNavController, animated: true)
}
func showFeedInspector() {

View File

@@ -495,7 +495,7 @@
<rect key="frame" x="20" y="11.5" width="217" height="32"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="accountLocal" translatesAutoresizingMaskIntoConstraints="NO" id="tb2-dO-AhR">
<rect key="frame" x="0.0" y="0.0" width="32" height="32.000000000000028"/>
<rect key="frame" x="0.0" y="0.0" width="32" height="32"/>
<color key="tintColor" cocoaTouchSystemColor="darkTextColor"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="0GF-vU-aEc"/>
@@ -610,7 +610,7 @@
<rect key="frame" x="79" y="128" width="256.5" height="41"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="accountLocal" translatesAutoresizingMaskIntoConstraints="NO" id="74E-kl-vU9">
<rect key="frame" x="0.0" y="4.5" width="32" height="32.000000000000028"/>
<rect key="frame" x="0.0" y="4.5" width="32" height="32"/>
<color key="tintColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="32" id="E7T-ps-KgX"/>

View File

@@ -12,6 +12,7 @@ import SafariServices
class SettingsViewController: UITableViewController {
private let appNewsURLString = "https://nnw.ranchero.com/feed.json"
static let preferredContentSizeForFormSheetDisplay = CGSize(width: 460.0, height: 400.0)
@IBOutlet weak var refreshIntervalLabel: UILabel!
@@ -77,6 +78,12 @@ class SettingsViewController: UITableViewController {
return defaultNumberOfRows - 1
}
return defaultNumberOfRows
case 3:
let defaultNumberOfRows = super.tableView(tableView, numberOfRowsInSection: section)
if AccountManager.shared.anyAccountHasFeedWithURL(appNewsURLString) {
return defaultNumberOfRows - 1
}
return defaultNumberOfRows
default:
return super.tableView(tableView, numberOfRowsInSection: section)
}
@@ -243,24 +250,17 @@ private extension SettingsViewController {
}
func addFeed() {
let appNewsURLString = "https://nnw.ranchero.com/feed.json"
if AccountManager.shared.anyAccountHasFeedWithURL(appNewsURLString) {
presentError(title: "Subscribe", message: "You are already subscribed to the NetNewsWire news feed.")
return
}
self.dismiss(animated: true)
let addNavViewController = UIStoryboard.add.instantiateInitialViewController() as! UINavigationController
let addViewController = addNavViewController.topViewController as! AddContainerViewController
addNavViewController.modalPresentationStyle = .formSheet
addNavViewController.preferredContentSize = AddContainerViewController.preferredContentSizeForFormSheetDisplay
addViewController.initialControllerType = .feed
addViewController.initialFeed = appNewsURLString
addViewController.initialFeedName = "NetNewsWire News"
presentingParentController?.present(addNavViewController, animated: true)
}
func importOPML() {