Fix images not being cached

Fixes #219
This commit is contained in:
Shadowfacts 2022-11-09 18:56:59 -05:00
parent 94dc5d3177
commit f7304a011c
1 changed files with 4 additions and 5 deletions

View File

@ -81,10 +81,7 @@ class ImageCache {
guard !ImageCache.disableCaching else { return } guard !ImageCache.disableCaching else { return }
if !((try? cache.has(url.absoluteString)) ?? false) { if !((try? cache.has(url.absoluteString)) ?? false) {
let task = dataTask(url: url) { data, image in let task = dataTask(url: url, completion: nil)
guard let data else { return }
try? self.cache.set(url.absoluteString, data: data, image: image)
}
task.resume() task.resume()
} }
} }
@ -95,7 +92,9 @@ class ImageCache {
let data else { let data else {
return return
} }
completion?(data, UIImage(data: data)) let image = UIImage(data: data)
try? self.cache.set(url.absoluteString, data: data, image: image)
completion?(data, image)
} }
} }