Skip to content

Commit

Permalink
only start placeholder op if doesn't exist in disk cache
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Apr 22, 2024
1 parent ef652b1 commit 18ba143
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/expo-bluesky-gif-view/ios/GifView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ public class GifView: ExpoView, AVPlayerViewControllerDelegate {
self.webpOperation?.cancel()
self.placeholderOperation?.cancel()

if let url = URL(string: placeholderSource) {
// We only need to start an operation for the placeholder if it doesn't exist
// in the cache already. Cache key is by default the absolute URL of the image.
// See:
// https://github.com/SDWebImage/SDWebImage/blob/master/Docs/HowToUse.md#using-asynchronous-image-caching-independently
if !SDImageCache.shared.diskImageDataExists(withKey: webpSource),
let url = URL(string: placeholderSource)
{
self.placeholderOperation = imageManager.loadImage(
with: url,
options: [.retryFailed],
Expand Down

0 comments on commit 18ba143

Please sign in to comment.