From d0852d89547e231934a27db18c749725caa69d5d Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 30 Mar 2020 10:56:52 -0500 Subject: [PATCH] Fix scenario where incorrect platform specific icon image could be returned. --- Shared/Extensions/RSImage-AppIcons.swift | 5 ++--- Shared/Images/WebFeedIconDownloader.swift | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Shared/Extensions/RSImage-AppIcons.swift b/Shared/Extensions/RSImage-AppIcons.swift index b0a778e7b..df5670732 100644 --- a/Shared/Extensions/RSImage-AppIcons.swift +++ b/Shared/Extensions/RSImage-AppIcons.swift @@ -27,11 +27,10 @@ extension RSImage { } extension IconImage { - static var appIcon: IconImage? { + static var appIcon: IconImage? = { if let image = RSImage.appIconImage { return IconImage(image) } - return nil - } + }() } diff --git a/Shared/Images/WebFeedIconDownloader.swift b/Shared/Images/WebFeedIconDownloader.swift index d62f5201c..bb67e2706 100644 --- a/Shared/Images/WebFeedIconDownloader.swift +++ b/Shared/Images/WebFeedIconDownloader.swift @@ -67,6 +67,10 @@ public final class WebFeedIconDownloader { return cachedImage } + if let hpURLString = feed.homePageURL, let hpURL = URL(string: hpURLString), hpURL.host == "nnw.ranchero.com" { + return IconImage.appIcon + } + func checkHomePageURL() { guard let homePageURL = feed.homePageURL else { return @@ -124,11 +128,6 @@ private extension WebFeedIconDownloader { func icon(forHomePageURL homePageURL: String, feed: WebFeed, _ imageResultBlock: @escaping (RSImage?) -> Void) { - if let url = URL(string: homePageURL), url.host == "nnw.ranchero.com" { - imageResultBlock(RSImage.appIconImage) - return - } - if homePagesWithNoIconURLCache.contains(homePageURL) || homePagesWithUglyIcons.contains(homePageURL) { imageResultBlock(nil) return