Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Kingfisher to fix a bug that prevented GIFs from being tapped. #3326

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7839,7 +7839,7 @@
repositoryURL = "https://github.com/onevcat/Kingfisher";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 7.6.0;
minimumVersion = 8.0.3;
};
};
D5F7D47BBAAE0CF1DDEB3034 /* XCRemoteSwiftPackageReference "DeviceKit" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
16 changes: 3 additions & 13 deletions ElementX/Sources/Services/Media/Provider/MediaProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down Expand Up @@ -149,13 +149,3 @@ struct MediaProvider: MediaProviderProtocol {
}
}
}

private extension ImageCache {
func retrieveImage(forKey key: String) async -> Result<ImageCacheResult, KingfisherError> {
await withCheckedContinuation { continuation in
retrieveImage(forKey: key) { result in
continuation.resume(returning: result)
}
}
}
}
3 changes: 2 additions & 1 deletion UnitTests/Sources/MediaProvider/MockImageCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -35,5 +35,6 @@ class MockImageCache: ImageCache {
callbackQueue: CallbackQueue = .untouch,
completionHandler: ((CacheStoreResult) -> Void)? = nil) {
storedImages[key] = image
completionHandler?(.init(memoryCacheResult: .success(()), diskCacheResult: .success(())))
}
}
2 changes: 1 addition & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading