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