mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-11 09:14:06 +01:00
Merge pull request #3850 from stuartbreckenridge/ios-release
Shows Twitter Deprecation Alert on iOS
This commit is contained in:
commit
33c4cfcc3a
@ -58,6 +58,7 @@ final class AppDefaults {
|
||||
static let addFolderAccountID = "addFolderAccountID"
|
||||
static let useSystemBrowser = "useSystemBrowser"
|
||||
static let currentThemeName = "currentThemeName"
|
||||
static let twitterDeprecationAlertShown = "twitterDeprecationAlertShown"
|
||||
}
|
||||
|
||||
let isDeveloperBuild: Bool = {
|
||||
@ -232,6 +233,15 @@ final class AppDefaults {
|
||||
}
|
||||
}
|
||||
|
||||
var twitterDeprecationAlertShown: Bool {
|
||||
get {
|
||||
return AppDefaults.bool(for: Key.twitterDeprecationAlertShown)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setBool(for: Key.twitterDeprecationAlertShown, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static func registerDefaults() {
|
||||
let defaults: [String : Any] = [Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue,
|
||||
Key.timelineGroupByFeed: false,
|
||||
|
@ -74,6 +74,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(configureContextMenu(_:)), name: .ActiveExtensionPointsDidChange, object: nil)
|
||||
|
||||
|
||||
refreshControl = UIRefreshControl()
|
||||
refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged)
|
||||
|
||||
@ -86,6 +87,16 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
super.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
if (isBeingPresented || isMovingToParent) {
|
||||
// Only show the Twitter alert the first time
|
||||
// the view is presented.
|
||||
presentTwitterDeprecationAlertIfRequired()
|
||||
}
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
if traitCollection.preferredContentSizeCategory != previousTraitCollection?.preferredContentSizeCategory {
|
||||
@ -703,6 +714,45 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
}
|
||||
}
|
||||
|
||||
private func presentTwitterDeprecationAlertIfRequired() {
|
||||
if AppDefaults.shared.twitterDeprecationAlertShown { return }
|
||||
|
||||
let expiryDate = Date(timeIntervalSince1970: 1691539200).timeIntervalSince1970 // August 9th 2023, 00:00 UTC
|
||||
let currentDate = Date().timeIntervalSince1970
|
||||
if currentDate > expiryDate {
|
||||
return // If after August 9th, don't show
|
||||
}
|
||||
|
||||
var twitterIsActive: Bool = false
|
||||
AccountManager.shared.accounts.forEach({ account in
|
||||
if account.type == .cloudKit || account.type == .onMyMac {
|
||||
account.flattenedWebFeeds().forEach({ webfeed in
|
||||
guard let components = URLComponents(string: webfeed.url),
|
||||
let host = components.host else {
|
||||
return
|
||||
}
|
||||
if host == "twitter.com" {
|
||||
twitterIsActive = true
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
if twitterIsActive {
|
||||
showTwitterDeprecationAlert()
|
||||
}
|
||||
AppDefaults.shared.twitterDeprecationAlertShown = true
|
||||
}
|
||||
|
||||
private func showTwitterDeprecationAlert() {
|
||||
let alert = UIAlertController(title: NSLocalizedString("Twitter Integration Removed", comment: "Twitter Integration Removed"),
|
||||
message: NSLocalizedString("On February 1, 2023, Twitter announced the end of free access to the Twitter API, effective February 9.\n\nSince Twitter does not provide RSS feeds, we’ve had to use the Twitter API. Without free access to that API, we can’t read feeds from Twitter.\n\nWe’ve left your Twitter 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. However, those feeds will no longer update.", comment: "Twitter deprecation message"),
|
||||
preferredStyle: .alert)
|
||||
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .cancel))
|
||||
present(alert, animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: UIContextMenuInteractionDelegate
|
||||
|
Loading…
Reference in New Issue
Block a user