diff --git a/Modules/Images/Sources/Images/FeedIconDownloader.swift b/Modules/Images/Sources/Images/FeedIconDownloader.swift index 143527a94..d80a47fe4 100644 --- a/Modules/Images/Sources/Images/FeedIconDownloader.swift +++ b/Modules/Images/Sources/Images/FeedIconDownloader.swift @@ -45,13 +45,6 @@ public extension Notification.Name { } private var homePagesWithNoIconURLCache = Set() - private var homePagesWithNoIconURLCachePath: URL - private var homePagesWithNoIconURLCacheDirty = false { - didSet { - queueHomePagesWithNoIconURLCacheIfNeeded() - } - } - private var homePagesWithUglyIcons: Set = { 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) - } - } }