From 43d9fc688e94506f66d9e2274ecf759bcf11065b Mon Sep 17 00:00:00 2001 From: Dan Cunningham Date: Wed, 18 Sep 2024 07:46:55 -0700 Subject: [PATCH] Fixes Sitemap image rendering issue. When loading sitemaps, i noticed many images were not rendering until i rotated my device, which forces a rerender of the view. This fixes that. Signed-off-by: Dan Cunningham --- openHAB/OpenHABSitemapViewController.swift | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/openHAB/OpenHABSitemapViewController.swift b/openHAB/OpenHABSitemapViewController.swift index 47d26f23..ffb437e7 100644 --- a/openHAB/OpenHABSitemapViewController.swift +++ b/openHAB/OpenHABSitemapViewController.swift @@ -710,21 +710,20 @@ extension OpenHABSitemapViewController: UITableViewDelegate, UITableViewDataSour ).url { var imageRequest = URLRequest(url: urlc) imageRequest.timeoutInterval = 10.0 - - let reportOnResults: ((Swift.Result) -> Void)? = { result in + cell.imageView?.kf.setImage( + with: KF.ImageResource(downloadURL: urlc, cacheKey: urlc.path + (urlc.query ?? "")), + placeholder: nil, + options: [.processor(OpenHABImageProcessor())] + ) { result in switch result { - case let .success(value): - os_log("Task done for: %{PUBLIC}@", log: .viewCycle, type: .info, value.source.url?.absoluteString ?? "") + case .success: + DispatchQueue.main.async { + cell.setNeedsLayout() + } case let .failure(error): - os_log("Job failed: %{PUBLIC}@", log: .viewCycle, type: .info, error.localizedDescription) + os_log("Image loading failed: %{PUBLIC}@", log: .viewCycle, type: .error, error.localizedDescription) } } - cell.imageView?.kf.setImage( - with: KF.ImageResource(downloadURL: urlc, cacheKey: urlc.path + (urlc.query ?? "")), - placeholder: nil, - options: [.processor(OpenHABImageProcessor())], - completionHandler: reportOnResults - ) } }