mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Stop saving the homePagesWithNoIconURLCache on disk — because it can become wrong when sites do add feed icons. This way it’s dropped between runs.
This commit is contained in:
@@ -45,13 +45,6 @@ public extension Notification.Name {
|
||||
}
|
||||
|
||||
private var homePagesWithNoIconURLCache = Set<String>()
|
||||
private var homePagesWithNoIconURLCachePath: URL
|
||||
private var homePagesWithNoIconURLCacheDirty = false {
|
||||
didSet {
|
||||
queueHomePagesWithNoIconURLCacheIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
private var homePagesWithUglyIcons: Set<String> = {
|
||||
return Set(["https://www.macsparky.com/", "https://xkcd.com/"])
|
||||
}()
|
||||
@@ -65,10 +58,8 @@ public extension Notification.Name {
|
||||
|
||||
self.feedURLToIconURLCachePath = folder.appendingPathComponent("FeedURLToIconURLCache.plist")
|
||||
self.homePageToIconURLCachePath = folder.appendingPathComponent("HomePageToIconURLCache.plist")
|
||||
self.homePagesWithNoIconURLCachePath = folder.appendingPathComponent("HomePagesWithNoIconURLCache.plist")
|
||||
loadFeedURLToIconURLCache()
|
||||
loadHomePageToIconURLCache()
|
||||
loadHomePagesWithNoIconURLCache()
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .ImageDidBecomeAvailable, object: imageDownloader)
|
||||
}
|
||||
|
||||
@@ -151,12 +142,6 @@ public extension Notification.Name {
|
||||
saveHomePageToIconURLCache()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func saveHomePagesWithNoIconURLCacheIfNeeded() {
|
||||
if homePagesWithNoIconURLCacheDirty {
|
||||
saveHomePagesWithNoIconURLCache()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension FeedIconDownloader {
|
||||
@@ -210,7 +195,6 @@ private extension FeedIconDownloader {
|
||||
|
||||
func cacheIconURL(for homePageURL: String, _ iconURL: String) {
|
||||
homePagesWithNoIconURLCache.remove(homePageURL)
|
||||
homePagesWithNoIconURLCacheDirty = true
|
||||
homePageToIconURLCache[homePageURL] = iconURL
|
||||
homePageToIconURLCacheDirty = true
|
||||
}
|
||||
@@ -231,15 +215,6 @@ private extension FeedIconDownloader {
|
||||
homePageToIconURLCache = (try? decoder.decode([String: String].self, from: data)) ?? [String: String]()
|
||||
}
|
||||
|
||||
func loadHomePagesWithNoIconURLCache() {
|
||||
guard let data = try? Data(contentsOf: homePagesWithNoIconURLCachePath) else {
|
||||
return
|
||||
}
|
||||
let decoder = PropertyListDecoder()
|
||||
let decoded = (try? decoder.decode([String].self, from: data)) ?? [String]()
|
||||
homePagesWithNoIconURLCache = Set(decoded)
|
||||
}
|
||||
|
||||
@MainActor func queueSaveFeedURLToIconURLCacheIfNeeded() {
|
||||
FeedIconDownloader.saveQueue.add(self, #selector(saveFeedURLToIconURLCacheIfNeeded))
|
||||
}
|
||||
@@ -248,10 +223,6 @@ private extension FeedIconDownloader {
|
||||
FeedIconDownloader.saveQueue.add(self, #selector(saveHomePageToIconURLCacheIfNeeded))
|
||||
}
|
||||
|
||||
@MainActor func queueHomePagesWithNoIconURLCacheIfNeeded() {
|
||||
FeedIconDownloader.saveQueue.add(self, #selector(saveHomePagesWithNoIconURLCacheIfNeeded))
|
||||
}
|
||||
|
||||
func saveFeedURLToIconURLCache() {
|
||||
feedURLToIconURLCacheDirty = false
|
||||
|
||||
@@ -277,17 +248,4 @@ private extension FeedIconDownloader {
|
||||
assertionFailure(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
|
||||
func saveHomePagesWithNoIconURLCache() {
|
||||
homePagesWithNoIconURLCacheDirty = false
|
||||
|
||||
let encoder = PropertyListEncoder()
|
||||
encoder.outputFormat = .binary
|
||||
do {
|
||||
let data = try encoder.encode(Array(homePagesWithNoIconURLCache))
|
||||
try data.write(to: homePagesWithNoIconURLCachePath)
|
||||
} catch {
|
||||
assertionFailure(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user