Skip to content

Commit 78d9bfb

Browse files
committed
Fix the context arg pass issue, should use the local variable
1 parent 94aadc1 commit 78d9bfb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

SDWebImageSwiftUI/Classes/ImageManager.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public final class ImageManager : ObservableObject {
109109
/// Prefetch the initial state of image, currently query the memory cache only
110110
func prefetch() {
111111
// Use the options processor if provided
112+
let options = self.options
112113
var context = self.context
113114
if let result = manager.optionsProcessor?.processedResult(for: url, options: options, context: context) {
114115
context = result.context
@@ -118,7 +119,7 @@ public final class ImageManager : ObservableObject {
118119
// This callback is synchronzied
119120
manager.imageCache.containsImage(forKey: key, cacheType: .memory) { [unowned self] (cacheType) in
120121
if cacheType == .memory {
121-
self.manager.imageCache.queryImage(forKey: key, options: self.options, context: self.context) { [unowned self] (image, data, cacheType) in
122+
self.manager.imageCache.queryImage(forKey: key, options: options, context: context) { [unowned self] (image, data, cacheType) in
122123
self.image = image
123124
}
124125
}

SDWebImageSwiftUI/Classes/WebImage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public struct WebImage : View {
5858
}
5959
self.imageManager = ImageManager(url: url, options: options, context: context)
6060
// this prefetch the memory cache of image, to immediately render it on screen
61-
// this solve the cause when `onAppear` not been called, for example, some transaction indetermite state :)
61+
// this solve the case when `onAppear` not been called, for example, some transaction indeterminate state, SwiftUI :)
6262
self.imageManager.prefetch()
6363
}
6464

0 commit comments

Comments
 (0)