Remove code for showing Twitter and Reddit deprecation alerts.

This commit is contained in:
Brent Simmons 2023-12-19 20:57:47 -08:00
parent 74b11219d1
commit a91ef3563e
3 changed files with 0 additions and 129 deletions

View File

@ -351,54 +351,6 @@ public final class AccountManager: UnreadCountProvider {
return false
}
public func anyLocalOriCloudAccountHasAtLeastOneTwitterFeed() -> Bool {
// We removed our Twitter code, and the ability to read feeds from Twitter,
// when Twitter announced the end of the free tier for the Twitter API.
// We are cheering on Twitters increasing irrelevancy.
for account in accounts {
if account.type == .cloudKit || account.type == .onMyMac {
for webfeed in account.flattenedWebFeeds() {
if let components = URLComponents(string: webfeed.url), let host = components.host {
if host == "twitter.com" { // Allow, for instance, blog.twitter.com, which might have an actual RSS feed
return true
}
}
}
}
}
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: feed.url), let host = components.host {
return host.hasSuffix("reddit.com") && !components.path.hasSuffix(".rss")
}
return false
}
// MARK: - Fetching Articles
// These fetch articles from active accounts and return a merged Set<Article>.

View File

@ -131,13 +131,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(didWakeNotification(_:)), name: NSWorkspace.didWakeNotification, object: nil)
appDelegate = self
if shouldShowTwitterDeprecationAlert() {
showTwitterDeprecationAlert()
}
else if shouldShowRedditDeprecationAlert() {
showRedditDeprecationAlert()
}
}
// MARK: - API
@ -944,60 +937,6 @@ internal extension AppDelegate {
}
}
private func shouldShowTwitterDeprecationAlert() -> Bool {
if AppDefaults.shared.twitterDeprecationAlertShown { return false }
let expiryDate = Date(timeIntervalSince1970: 1691539200) // August 9th 2023, 00:00 UTC
let currentDate = Date()
if currentDate > expiryDate {
return false // If after August 9th, don't show
}
return AccountManager.shared.anyLocalOriCloudAccountHasAtLeastOneTwitterFeed()
}
private func showTwitterDeprecationAlert() {
assert(shouldShowTwitterDeprecationAlert())
AppDefaults.shared.twitterDeprecationAlertShown = true
DispatchQueue.main.async {
let alert = NSAlert()
alert.alertStyle = .warning
alert.messageText = NSLocalizedString("Twitter Integration Removed", comment: "Twitter Integration Removed")
alert.informativeText = NSLocalizedString("Twitter has ended free access to the parts of the Twitter API that we need.\n\nSince Twitter does not provide RSS feeds, weve had to use the Twitter API. Without free access to that API, we cant read feeds from Twitter.\n\nWeve left your Twitter 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. However, those feeds will no longer update.", comment: "Twitter deprecation informative text.")
alert.addButton(withTitle: NSLocalizedString("OK", comment: "OK"))
alert.buttons[0].keyEquivalent = "\r"
alert.runModal()
}
}
private func shouldShowRedditDeprecationAlert() -> Bool {
if AppDefaults.shared.redditDeprecationAlertShown { return false }
let expiryDate = Date(timeIntervalSince1970: 1701331200) // Thu Nov 30 2023 00:00:00 GMT-0800 (Pacific Standard Time)
let currentDate = Date()
if currentDate > expiryDate {
return false
}
return AccountManager.shared.anyLocalOriCloudAccountHasAtLeastOneRedditAPIFeed()
}
private func showRedditDeprecationAlert() {
assert(shouldShowRedditDeprecationAlert())
AppDefaults.shared.redditDeprecationAlertShown = true
DispatchQueue.main.async {
let alert = NSAlert()
alert.alertStyle = .warning
alert.messageText = NSLocalizedString("Reddit API Integration Removed", comment: "Reddit API Integration Removed")
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()
}
}
@objc func openThemesFolder(_ sender: Any) {
if themeImportPath == nil {
let url = URL(fileURLWithPath: ArticleThemesManager.shared.folderPath)

View File

@ -57,8 +57,6 @@ final class AppDefaults {
static let addFolderAccountID = "addFolderAccountID"
static let useSystemBrowser = "useSystemBrowser"
static let currentThemeName = "currentThemeName"
static let twitterDeprecationAlertShown = "twitterDeprecationAlertShown"
static let redditDeprecationAlertShown = "redditDeprecationAlertShown"
}
let isDeveloperBuild: Bool = {
@ -224,24 +222,6 @@ final class AppDefaults {
}
}
var twitterDeprecationAlertShown: Bool {
get {
return AppDefaults.bool(for: Key.twitterDeprecationAlertShown)
}
set {
AppDefaults.setBool(for: Key.twitterDeprecationAlertShown, newValue)
}
}
var redditDeprecationAlertShown: Bool {
get {
return AppDefaults.bool(for: Key.redditDeprecationAlertShown)
}
set {
AppDefaults.setBool(for: Key.redditDeprecationAlertShown, newValue)
}
}
static func registerDefaults() {
let defaults: [String : Any] = [Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue,
Key.timelineGroupByFeed: false,