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

add a switch to ignore internal image cache #2171

Merged
merged 7 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private final class CachedImageProvider: AnimationImageProvider {
// MARK: Public

public func imageForAsset(asset: ImageAsset) -> CGImage? {
if let image = imageCache.object(forKey: asset.id as NSString) {
if imageProvider.ignoreInternalImageCache == false, let image = imageCache.object(forKey: asset.id as NSString) {
return image
}
if let image = imageProvider.imageForAsset(asset: asset) {
Expand Down
10 changes: 10 additions & 0 deletions Sources/Public/ImageProvider/AnimationImageProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@ import Foundation
/// Additionally custom Image Providers can be made to load images from a URL,
/// or to Cache images.
public protocol AnimationImageProvider {

var ignoreInternalImageCache: Bool { get set }

calda marked this conversation as resolved.
Show resolved Hide resolved
func imageForAsset(asset: ImageAsset) -> CGImage?
calda marked this conversation as resolved.
Show resolved Hide resolved
}

public extension AnimationImageProvider {
var ignoreInternalImageCache: Bool {
get { return false }
set { }
}
}
Loading