Skip to content

Commit

Permalink
Fixes Sitemap image rendering issue. (#831)
Browse files Browse the repository at this point in the history
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 <dan@digitaldan.com>
  • Loading branch information
digitaldan authored Sep 18, 2024
1 parent 6754e0c commit a61e9f4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions openHAB/OpenHABSitemapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -713,21 +713,20 @@ extension OpenHABSitemapViewController: UITableViewDelegate, UITableViewDataSour
).url {
var imageRequest = URLRequest(url: urlc)
imageRequest.timeoutInterval = 10.0

let reportOnResults: ((Swift.Result<RetrieveImageResult, KingfisherError>) -> 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
)
}
}

Expand Down

0 comments on commit a61e9f4

Please sign in to comment.