damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 649a857c3ac01b43e6a22ab7d809494f1035906c
parent b35cc33c3266e7249331fbeb45272b743a2fe01e
Author: Daniel D’Aquino <daniel@daquino.me>
Date:   Thu,  3 Apr 2025 15:07:17 -0700

Update Kingfisher to 8.3.1

Changelog-Changed: Updated image cache for better stability
Closes: https://github.com/damus-io/damus/issues/2899
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>

Diffstat:
Mdamus.xcodeproj/project.pbxproj | 2+-
Mdamus.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4++--
Mdamus/Util/EventCache.swift | 2+-
Mdamus/Util/Extensions/KFOptionSetter+.swift | 17+++++++++++------
4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj @@ -6862,7 +6862,7 @@ repositoryURL = "https://github.com/onevcat/Kingfisher"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 7.0.0; + minimumVersion = 8.3.1; }; }; 4C27C9302A64766F007DBC75 /* XCRemoteSwiftPackageReference "swift-markdown-ui" */ = { diff --git a/damus.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/damus.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -49,8 +49,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/onevcat/Kingfisher", "state" : { - "revision" : "415b1d97fb38bda1e5a6b2dde63354720832110b", - "version" : "7.6.1" + "revision" : "4c6b067f96953ee19526e49e4189403a2be21fb3", + "version" : "8.3.1" } }, { diff --git a/damus/Util/EventCache.swift b/damus/Util/EventCache.swift @@ -354,7 +354,7 @@ func preload_image(url: URL) { //print("Preloading image \(url.absoluteString)") - KingfisherManager.shared.retrieveImage(with: Kingfisher.ImageResource(downloadURL: url)) { val in + KingfisherManager.shared.retrieveImage(with: Kingfisher.KF.ImageResource(downloadURL: url)) { val in //print("Preloaded image \(url.absoluteString)") } } diff --git a/damus/Util/Extensions/KFOptionSetter+.swift b/damus/Util/Extensions/KFOptionSetter+.swift @@ -52,7 +52,7 @@ extension KFOptionSetter { func onFailure(fallbackUrl: URL?, cacheKey: String?) -> Self { guard let url = fallbackUrl, let key = cacheKey else { return self } - let imageResource = Kingfisher.ImageResource(downloadURL: url, cacheKey: key) + let imageResource = Kingfisher.KF.ImageResource(downloadURL: url, cacheKey: key) let source = imageResource.convertToSource() options.alternativeSources = [source] @@ -159,20 +159,25 @@ struct CustomCacheSerializer: CacheSerializer { } } -class CustomSessionDelegate: SessionDelegate { - override func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) { +class CustomSessionDelegate: SessionDelegate, @unchecked Sendable { + override func urlSession( + _ session: URLSession, + dataTask: URLSessionDataTask, + didReceive response: URLResponse + ) async -> URLSession.ResponseDisposition { let contentLength = response.expectedContentLength // Content-Length header is optional (-1 when missing) if (contentLength != -1 && contentLength > MAX_FILE_SIZE) { - return super.urlSession(session, dataTask: dataTask, didReceive: URLResponse(), completionHandler: completionHandler) + return await super.urlSession(session, dataTask: dataTask, didReceive: URLResponse()) } - super.urlSession(session, dataTask: dataTask, didReceive: response, completionHandler: completionHandler) + return await super.urlSession(session, dataTask: dataTask, didReceive: response) } } -class CustomImageDownloader: ImageDownloader { + +class CustomImageDownloader: ImageDownloader, @unchecked Sendable { static let shared = CustomImageDownloader(name: "shared")