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 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)
|
let scaledIconImage = IconImage(scaledImage)
|
||||||
cache[feed] = scaledIconImage
|
cache[feed] = scaledIconImage
|
||||||
return scaledIconImage
|
return scaledIconImage
|
||||||
|
@ -29,10 +29,10 @@ extension RSImage {
|
|||||||
|
|
||||||
static func scaledForIcon(_ data: Data) async -> 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 {
|
guard var cgImage = RSImage.scaleImage(data, maxPixelSize: Self.scaledMaxPixelSize) else {
|
||||||
return nil
|
return nil
|
||||||
@ -46,34 +46,3 @@ extension RSImage {
|
|||||||
#endif
|
#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…
x
Reference in New Issue
Block a user