diff --git a/Images/Sources/Images/Favicons/FaviconDownloader.swift b/Images/Sources/Images/Favicons/FaviconDownloader.swift index dbc467342..62017f6cb 100644 --- a/Images/Sources/Images/Favicons/FaviconDownloader.swift +++ b/Images/Sources/Images/Favicons/FaviconDownloader.swift @@ -109,7 +109,7 @@ public protocol FaviconDownloaderDelegate { } if let iconImage = favicon(for: feed), let imageData = iconImage.image.dataRepresentation() { - if let scaledImage = RSImage.scaledForIcon(imageData) { + if let scaledImage = RSImage.scaledForIconSync(imageData) { let scaledIconImage = IconImage(scaledImage) cache[feed] = scaledIconImage return scaledIconImage @@ -164,7 +164,7 @@ public protocol FaviconDownloaderDelegate { @objc func didLoadFavicon(_ note: Notification) { assert(Thread.isMainThread) - + guard let singleFaviconDownloader = note.object as? SingleFaviconDownloader else { return } diff --git a/Images/Sources/Images/RSImage-Extensions.swift b/Images/Sources/Images/RSImage-Extensions.swift index 1737de3f5..4fcd62ad7 100644 --- a/Images/Sources/Images/RSImage-Extensions.swift +++ b/Images/Sources/Images/RSImage-Extensions.swift @@ -29,10 +29,10 @@ extension RSImage { static func scaledForIcon(_ data: Data) async -> RSImage? { - await IconScalerQueue.shared.scaledForIcon(data) + RSImage.scaledForIconSync(data) } - static func scaledForIcon(_ data: Data) -> RSImage? { + static func scaledForIconSync(_ data: Data) -> RSImage? { guard var cgImage = RSImage.scaleImage(data, maxPixelSize: Self.scaledMaxPixelSize) else { return nil @@ -46,34 +46,3 @@ extension RSImage { #endif } } - -// MARK: - IconScalerQueue - -private final class IconScalerQueue: @unchecked Sendable { - - static let shared = IconScalerQueue() - - private let queue: DispatchQueue = { - let q = DispatchQueue(label: "IconScaler", attributes: .initiallyInactive) - q.setTarget(queue: DispatchQueue.global(qos: .default)) - q.activate() - return q - }() - - private func scaledForIcon(_ data: Data, _ imageResultBlock: @escaping ImageResultBlock) { - queue.async { - let image = RSImage.scaledForIcon(data) - imageResultBlock(image) - } - } - - func scaledForIcon(_ data: Data) async -> RSImage? { - - await withCheckedContinuation { continuation in - - self.scaledForIcon(data) { image in - continuation.resume(returning: image) - } - } - } -}