From 7c91a1df3a76e786cf2f2d7ca4eeef296633f1c6 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 29 Oct 2020 17:52:58 -0500 Subject: [PATCH] Change NetNewsWire News URL to use the XML version since some sync services don't understand JSON. --- Account/Sources/Account/AccountManager.swift | 8 +++++++- Mac/AppDelegate.swift | 7 +++---- Multiplatform/macOS/AppDelegate.swift | 1 - iOS/Settings/SettingsViewController.swift | 5 ++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Account/Sources/Account/AccountManager.swift b/Account/Sources/Account/AccountManager.swift index 08adff76d..39f3b6aef 100644 --- a/Account/Sources/Account/AccountManager.swift +++ b/Account/Sources/Account/AccountManager.swift @@ -17,7 +17,9 @@ import ArticlesDatabase public final class AccountManager: UnreadCountProvider { public static var shared: AccountManager! - + public static let netNewsWireNewsURL = "https://nnw.ranchero.com/feed.xml" + private static let jsonNetNewsWireNewsURL = "https://nnw.ranchero.com/feed.json" + public let defaultAccount: Account private let accountsFolder: String @@ -319,6 +321,10 @@ public final class AccountManager: UnreadCountProvider { return false } + + public func anyAccountHasNetNewsWireNewsSubscription() -> Bool { + return anyAccountHasFeedWithURL(Self.netNewsWireNewsURL) || anyAccountHasFeedWithURL(Self.jsonNetNewsWireNewsURL) + } public func anyAccountHasFeedWithURL(_ urlString: String) -> Bool { for account in activeAccounts { diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index 949492b40..95c1a1517 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -98,7 +98,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, private var inspectorWindowController: InspectorWindowController? private var crashReportWindowController: CrashReportWindowController? // For testing only private let log = Log() - private let appNewsURLString = "https://nnw.ranchero.com/feed.json" private let appMovementMonitor = RSAppMovementMonitor() #if !MAC_APP_STORE && !TEST private var softwareUpdater: SPUUpdater! @@ -424,7 +423,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, } if item.action == #selector(addAppNews(_:)) { - return !isDisplayingSheet && !AccountManager.shared.anyAccountHasFeedWithURL(appNewsURLString) && !AccountManager.shared.activeAccounts.isEmpty + return !isDisplayingSheet && !AccountManager.shared.anyAccountHasNetNewsWireNewsSubscription() && !AccountManager.shared.activeAccounts.isEmpty } if item.action == #selector(sortByNewestArticleOnTop(_:)) || item.action == #selector(sortByOldestArticleOnTop(_:)) { @@ -591,10 +590,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, } @IBAction func addAppNews(_ sender: Any?) { - if AccountManager.shared.anyAccountHasFeedWithURL(appNewsURLString) { + if AccountManager.shared.anyAccountHasNetNewsWireNewsSubscription() { return } - addWebFeed(appNewsURLString, name: "NetNewsWire News") + addWebFeed(AccountManager.netNewsWireNewsURL, name: "NetNewsWire News") } @IBAction func openWebsite(_ sender: Any?) { diff --git a/Multiplatform/macOS/AppDelegate.swift b/Multiplatform/macOS/AppDelegate.swift index 0f6f0d23d..1174c3fdf 100644 --- a/Multiplatform/macOS/AppDelegate.swift +++ b/Multiplatform/macOS/AppDelegate.swift @@ -62,7 +62,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele var appName: String! - private let appNewsURLString = "https://nnw.ranchero.com/feed.json" private let appMovementMonitor = RSAppMovementMonitor() #if !MAC_APP_STORE && !TEST var softwareUpdater: SPUUpdater! diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift index 0782867f8..954f181bb 100644 --- a/iOS/Settings/SettingsViewController.swift +++ b/iOS/Settings/SettingsViewController.swift @@ -13,7 +13,6 @@ import SafariServices class SettingsViewController: UITableViewController { - private let appNewsURLString = "https://nnw.ranchero.com/feed.json" private weak var opmlAccount: Account? @IBOutlet weak var timelineSortOrderSwitch: UISwitch! @@ -114,7 +113,7 @@ class SettingsViewController: UITableViewController { return ExtensionPointManager.shared.activeExtensionPoints.count + 1 case 3: let defaultNumberOfRows = super.tableView(tableView, numberOfRowsInSection: section) - if AccountManager.shared.activeAccounts.isEmpty || AccountManager.shared.anyAccountHasFeedWithURL(appNewsURLString) { + if AccountManager.shared.activeAccounts.isEmpty || AccountManager.shared.anyAccountHasNetNewsWireNewsSubscription() { return defaultNumberOfRows - 1 } return defaultNumberOfRows @@ -377,7 +376,7 @@ private extension SettingsViewController { let addNavViewController = UIStoryboard.add.instantiateViewController(withIdentifier: "AddWebFeedViewControllerNav") as! UINavigationController let addViewController = addNavViewController.topViewController as! AddFeedViewController - addViewController.initialFeed = appNewsURLString + addViewController.initialFeed = AccountManager.netNewsWireNewsURL addViewController.initialFeedName = NSLocalizedString("NetNewsWire News", comment: "NetNewsWire News") addNavViewController.modalPresentationStyle = .formSheet addNavViewController.preferredContentSize = AddFeedViewController.preferredContentSizeForFormSheetDisplay