Create and use API to determine if there are any feeds that require the Reddit API.

This commit is contained in:
Brent Simmons 2023-06-25 15:01:53 -07:00
parent 8a9481b621
commit 4dd3d60c78
2 changed files with 31 additions and 3 deletions

View File

@ -370,7 +370,35 @@ public final class AccountManager: UnreadCountProvider {
return false
}
public func anyLocalOriCloudAccountHasAtLeastOneRedditAPIFeed() -> Bool {
// We removed our Reddit code, and the ability to read feeds from Reddit,
// when Reddit announced the end of the free tier for the Reddit API.
// We are cheering on Reddits increasing irrelevancy.
for account in accounts {
if account.type == .cloudKit || account.type == .onMyMac {
for webfeed in account.flattenedWebFeeds() {
if feedRequiresRedditAPI(webfeed) {
return true
}
}
}
}
return false
}
/// Return true if a feed is for reddit.com and the path doesnt end with .rss.
///
/// More info: [Pathogen-David's Guide to RSS and Reddit!](https://www.reddit.com/r/pathogendavid/comments/tv8m9/pathogendavids_guide_to_rss_and_reddit/)
private func feedRequiresRedditAPI(_ feed: WebFeed) -> Bool {
if let components = URLComponents(string: webfeed.url), let host = components.host {
return host.hasSuffix("reddit.com") && !path.hasSuffix(".rss")
}
return false
}
// MARK: - Fetching Articles
// These fetch articles from active accounts and return a merged Set<Article>.

View File

@ -995,7 +995,7 @@ internal extension AppDelegate {
return false
}
return ExtensionPointManager.shared.isRedditEnabled
return AccountManager.shared.anyLocalOriCloudAccountHasAtLeastOneRedditAPIFeed()
}
private func showRedditDeprecationAlert() {
@ -1006,7 +1006,7 @@ internal extension AppDelegate {
let alert = NSAlert()
alert.alertStyle = .warning
alert.messageText = NSLocalizedString("Reddit API Integration Removed", comment: "Reddit API Integration Removed")
alert.informativeText = NSLocalizedString("Reddit has announced the end of free access to their API, effective July 1.\n\nThough Reddit does provide RSS feeds, we use the Reddit API to get more and better data. But, without free access to that API, we will stop using it on June 30, 2023.\n\nWeve left your Reddit feeds intact. If you have any starred items from those feeds, they will remain as long as you dont delete those feeds.\n\nYou can still read whatever you have already downloaded.\n\nAlso, importantly — after you remove Reddit from your extensions in NetNewsWire, you can add Reddit RSS feeds and those feeds will continue to update.", comment: "Reddit deprecation message")
alert.informativeText = NSLocalizedString("Reddit has ended free access to their API.\n\nThough Reddit does provide RSS feeds, we used the Reddit API to get more and better data. But, without free access to that API, we have had to stop using it.\n\nWeve left your Reddit feeds intact. If you have any starred items from those feeds, they will remain as long as you dont delete those feeds.\n\nYou can still read whatever you have already downloaded.\n\nAlso, importantly — Reddit still provides RSS feeds, and you can follow Reddit activity through RSS.", comment: "Reddit deprecation message")
alert.addButton(withTitle: NSLocalizedString("OK", comment: "OK"))
alert.buttons[0].keyEquivalent = "\r"
alert.runModal()