mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-23 08:09:41 +01:00
Delete unneeded IconScalerQueue.
This commit is contained in:
parent
167e8c1430
commit
d4c923a3d6
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user