From dc4804dd7196eeee3ce35cf9fef80f84cabac5cc Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 3 Nov 2026 10:11:52 -0800 Subject: [PATCH] Use saved home page icon before checking home page when a feed specified icon fails. --- .../Sources/Images/FeedIconDownloader.swift | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Modules/Images/Sources/Images/FeedIconDownloader.swift b/Modules/Images/Sources/Images/FeedIconDownloader.swift index 9d7853c01..94fc871d2 100644 --- a/Modules/Images/Sources/Images/FeedIconDownloader.swift +++ b/Modules/Images/Sources/Images/FeedIconDownloader.swift @@ -73,6 +73,19 @@ extension Notification.Name { } } + @MainActor func checkSavedHomePageIconURL(_ savedIconURL: String) { + icon(forURL: savedIconURL, feed: feed) { iconImage, isDefinitive in + if let iconImage { + if self.cacheIcon(iconImage, for: feed, isFeedOwnIcon: false) { + self.postFeedIconDidBecomeAvailableNotification(feed) + } + } else if self.cache[feed] == nil, isDefinitive { + // The site may have moved its icon, so the home page is checked again. + checkHomePageURL() + } + } + } + @MainActor func checkFeedIconURL() { if let iconURL = feed.iconURL, !Self.shouldIgnoreFeedIconURL(feed) { icon(forURL: iconURL, feed: feed) { (iconImage, isDefinitive) in @@ -85,7 +98,12 @@ extension Notification.Name { // The declared icon failed or isn’t an image. A still-downloading // icon is no reason to fall back to the home page’s icon. // - checkHomePageURL() + // A home page icon found earlier works without the home page’s metadata. + if let savedIconURL = ImageDatabase.shared.iconURL(forFeedURL: feed.url) { + checkSavedHomePageIconURL(savedIconURL) + } else { + checkHomePageURL() + } } } } @@ -95,16 +113,7 @@ extension Notification.Name { } if let previouslyFoundIconURL = Self.savedHomePageIconURL(for: feed) { - icon(forURL: previouslyFoundIconURL, feed: feed) { iconImage, isDefinitive in - if let iconImage { - if self.cacheIcon(iconImage, for: feed, isFeedOwnIcon: false) { - self.postFeedIconDidBecomeAvailableNotification(feed) - } - } else if self.cache[feed] == nil, isDefinitive { - // The site may have moved its icon, so the home page is checked again. - checkHomePageURL() - } - } + checkSavedHomePageIconURL(previouslyFoundIconURL) checkForNewHomePageIconURL(feed, savedIconURL: previouslyFoundIconURL) return nil