mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Show Reddit deprecation alert if needed.
This commit is contained in:
parent
21ee96609a
commit
e6a25f374a
@ -43,6 +43,7 @@ final class AppDefaults {
|
||||
static let defaultBrowserID = "defaultBrowserID"
|
||||
static let currentThemeName = "currentThemeName"
|
||||
static let twitterDeprecationAlertShown = "twitterDeprecationAlertShown"
|
||||
static let redditDeprecationAlertShown = "redditDeprecationAlertShown"
|
||||
|
||||
// Hidden prefs
|
||||
static let showDebugMenu = "ShowDebugMenu"
|
||||
@ -319,6 +320,14 @@ final class AppDefaults {
|
||||
}
|
||||
}
|
||||
|
||||
var redditDeprecationAlertShown: Bool {
|
||||
get {
|
||||
return AppDefaults.bool(for: Key.redditDeprecationAlertShown)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setBool(for: Key.redditDeprecationAlertShown, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
func registerDefaults() {
|
||||
#if DEBUG
|
||||
|
@ -133,7 +133,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
|
||||
appDelegate = self
|
||||
|
||||
presentTwitterDeprecationAlertIfRequired()
|
||||
if shouldShowTwitterDeprecationAlert() {
|
||||
showTwitterDeprecationAlert()
|
||||
}
|
||||
else if shouldShowRedditDeprecationAlert() {
|
||||
showRedditDeprecationAlert()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
@ -953,23 +958,23 @@ internal extension AppDelegate {
|
||||
alert.runModal()
|
||||
}
|
||||
}
|
||||
|
||||
private func presentTwitterDeprecationAlertIfRequired() {
|
||||
if AppDefaults.shared.twitterDeprecationAlertShown { return }
|
||||
|
||||
|
||||
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 // If after August 9th, don't show
|
||||
return false // If after August 9th, don't show
|
||||
}
|
||||
|
||||
if AccountManager.shared.anyLocalOriCloudAccountHasAtLeastOneTwitterFeed() {
|
||||
showTwitterDeprecationAlert()
|
||||
}
|
||||
AppDefaults.shared.twitterDeprecationAlertShown = true
|
||||
return AccountManager.shared.anyLocalOriCloudAccountHasAtLeastOneTwitterFeed()
|
||||
}
|
||||
|
||||
|
||||
private func showTwitterDeprecationAlert() {
|
||||
assert(shouldShowTwitterDeprecationAlert())
|
||||
|
||||
AppDefaults.shared.twitterDeprecationAlertShown = true
|
||||
DispatchQueue.main.async {
|
||||
let alert = NSAlert()
|
||||
alert.alertStyle = .warning
|
||||
@ -980,7 +985,34 @@ internal extension AppDelegate {
|
||||
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 ExtensionPointManager.shared.isRedditEnabled
|
||||
}
|
||||
|
||||
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 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\nWe’ve left your Reddit feeds intact. If you have any starred items from those feeds, they will remain as long as you don’t 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.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)
|
||||
|
Loading…
Reference in New Issue
Block a user