From f7304a011cc49b3a379444ed84a364a48024c2bd Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 9 Nov 2022 18:56:59 -0500 Subject: [PATCH] Fix images not being cached Fixes #219 --- Tusker/Caching/ImageCache.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Tusker/Caching/ImageCache.swift b/Tusker/Caching/ImageCache.swift index b3a222d9..e9bfa3da 100644 --- a/Tusker/Caching/ImageCache.swift +++ b/Tusker/Caching/ImageCache.swift @@ -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) } }