~ knotless Search/
↑↓ move↵ open⇧↵ all results

grain.social/grain-ios

1 collaborator
0
1
main
11 lines · 523 B Raw History
import Foundation
import Nuke

/// Returns `true` if the fullsize image for `story` is already in `pipeline`'s memory cache.
///
/// Extracted from `StoryViewer` so it can be tested without spinning up a SwiftUI view
/// and without touching `ImagePipeline.shared`.
func storyFullsizeCached(_ story: GrainStory?, in pipeline: ImagePipeline = .shared) -> Bool {
    guard let url = story.flatMap({ URL(string: $0.fullsize) }) else { return false }
    return pipeline.cache.cachedImage(for: ImageRequest(url: url)) != nil
}