Add and use anyLocalOriCloudAccountHasAtLeastOneTwitterFeed in AccountManager. Simplify date comparison code.
This commit is contained in:
parent
31fa19c57c
commit
e7ae7887e3
|
@ -351,6 +351,26 @@ public final class AccountManager: UnreadCountProvider {
|
||||||
return false
|
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 Twitter’s 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
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Fetching Articles
|
// MARK: - Fetching Articles
|
||||||
|
|
||||||
// These fetch articles from active accounts and return a merged Set<Article>.
|
// These fetch articles from active accounts and return a merged Set<Article>.
|
||||||
|
|
|
@ -957,28 +957,13 @@ internal extension AppDelegate {
|
||||||
private func presentTwitterDeprecationAlertIfRequired() {
|
private func presentTwitterDeprecationAlertIfRequired() {
|
||||||
if AppDefaults.shared.twitterDeprecationAlertShown { return }
|
if AppDefaults.shared.twitterDeprecationAlertShown { return }
|
||||||
|
|
||||||
let expiryDate = Date(timeIntervalSince1970: 1691539200).timeIntervalSince1970 // August 9th 2023, 00:00 UTC
|
let expiryDate = Date(timeIntervalSince1970: 1691539200) // August 9th 2023, 00:00 UTC
|
||||||
let currentDate = Date().timeIntervalSince1970
|
let currentDate = Date()
|
||||||
if currentDate > expiryDate {
|
if currentDate > expiryDate {
|
||||||
return // If after August 9th, don't show
|
return // If after August 9th, don't show
|
||||||
}
|
}
|
||||||
|
|
||||||
var twitterIsActive: Bool = false
|
if AccountManager.shared.anyLocalOriCloudAccountHasAtLeastOneTwitterFeed() {
|
||||||
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()
|
showTwitterDeprecationAlert()
|
||||||
}
|
}
|
||||||
AppDefaults.shared.twitterDeprecationAlertShown = true
|
AppDefaults.shared.twitterDeprecationAlertShown = true
|
||||||
|
|
Loading…
Reference in New Issue