From f52ed2f9291fb2914b0c45bf4f30a43bb0393e14 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:10:02 +0100 Subject: [PATCH] Upgrade Kingfisher to fix a bug that prevented GIFs from being tapped. (#3326) * Upgrade Kingfisher to fix a bug the prevented GIFs from being tapped. https://github.com/onevcat/Kingfisher/issues/2295 * Fix tests. --- ElementX.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../Services/Media/Provider/MediaProvider.swift | 16 +++------------- .../Sources/MediaProvider/MockImageCache.swift | 3 ++- project.yml | 2 +- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index b29471d75..d502d9380 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -7839,7 +7839,7 @@ repositoryURL = "https://github.com/onevcat/Kingfisher"; requirement = { kind = upToNextMinorVersion; - minimumVersion = 7.6.0; + minimumVersion = 8.0.3; }; }; D5F7D47BBAAE0CF1DDEB3034 /* XCRemoteSwiftPackageReference "DeviceKit" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7afb65f79..dfbedefd5 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/onevcat/Kingfisher", "state" : { - "revision" : "af4be924ad984cf4d16f4ae4df424e79a443d435", - "version" : "7.6.2" + "revision" : "33696a71dd4d71f1b0f781ade11a48ba5549581a", + "version" : "8.0.3" } }, { diff --git a/ElementX/Sources/Services/Media/Provider/MediaProvider.swift b/ElementX/Sources/Services/Media/Provider/MediaProvider.swift index b87f42603..408e85874 100644 --- a/ElementX/Sources/Services/Media/Provider/MediaProvider.swift +++ b/ElementX/Sources/Services/Media/Provider/MediaProvider.swift @@ -38,8 +38,8 @@ struct MediaProvider: MediaProviderProtocol { } let cacheKey = cacheKeyForURL(source.url, size: size) - - if case let .success(cacheResult) = await imageCache.retrieveImage(forKey: cacheKey), + + if let cacheResult = try? await imageCache.retrieveImage(forKey: cacheKey, options: nil), let image = cacheResult.image { return .success(image) } @@ -57,7 +57,7 @@ struct MediaProvider: MediaProviderProtocol { return .failure(.invalidImageData) } - imageCache.store(image, forKey: cacheKey) + try await imageCache.store(image, forKey: cacheKey) return .success(image) } catch { @@ -149,13 +149,3 @@ struct MediaProvider: MediaProviderProtocol { } } } - -private extension ImageCache { - func retrieveImage(forKey key: String) async -> Result { - await withCheckedContinuation { continuation in - retrieveImage(forKey: key) { result in - continuation.resume(returning: result) - } - } - } -} diff --git a/UnitTests/Sources/MediaProvider/MockImageCache.swift b/UnitTests/Sources/MediaProvider/MockImageCache.swift index 4e49317e6..64c41bde5 100644 --- a/UnitTests/Sources/MediaProvider/MockImageCache.swift +++ b/UnitTests/Sources/MediaProvider/MockImageCache.swift @@ -5,7 +5,7 @@ // Please see LICENSE in the repository root for full details. // @testable import ElementX -import Kingfisher +@testable import Kingfisher import UIKit class MockImageCache: ImageCache { @@ -35,5 +35,6 @@ class MockImageCache: ImageCache { callbackQueue: CallbackQueue = .untouch, completionHandler: ((CacheStoreResult) -> Void)? = nil) { storedImages[key] = image + completionHandler?(.init(memoryCacheResult: .success(()), diskCacheResult: .success(()))) } } diff --git a/project.yml b/project.yml index 45505258a..281902718 100644 --- a/project.yml +++ b/project.yml @@ -106,7 +106,7 @@ packages: minorVersion: 4.2.0 Kingfisher: url: https://github.com/onevcat/Kingfisher - minorVersion: 7.6.0 + minorVersion: 8.0.3 KZFileWatchers: url: https://github.com/krzysztofzablocki/KZFileWatchers minorVersion: 1.2.0