Fix ImageCache.get completion not being called when image isn't loaded

This commit is contained in:
Shadowfacts 2022-11-01 22:12:26 -04:00
parent 59d866aa23
commit abb8352c92
1 changed files with 12 additions and 8 deletions

View File

@ -37,15 +37,19 @@ class ImageCache {
let wrappedCompletion: ((Data?, UIImage?) -> Void)? let wrappedCompletion: ((Data?, UIImage?) -> Void)?
if let completion = completion { if let completion = completion {
wrappedCompletion = { (data, image) in wrappedCompletion = { (data, image) in
if !loadOriginal, if let image {
let size = self.desiredPixelSize { if !loadOriginal,
image?.prepareThumbnail(of: size, completionHandler: { let size = self.desiredPixelSize {
completion(data, $0) image.prepareThumbnail(of: size) {
}) completion(data, $0)
} else { }
image?.prepareForDisplay { } else {
completion(data, $0) image.prepareForDisplay {
completion(data, $0)
}
} }
} else {
completion(data, image)
} }
} }
} else { } else {