Fix the context arg pass issue, should use the local variable
This commit is contained in:
parent
94aadc1927
commit
78d9bfbb60
|
@ -109,6 +109,7 @@ public final class ImageManager : ObservableObject {
|
|||
/// Prefetch the initial state of image, currently query the memory cache only
|
||||
func prefetch() {
|
||||
// Use the options processor if provided
|
||||
let options = self.options
|
||||
var context = self.context
|
||||
if let result = manager.optionsProcessor?.processedResult(for: url, options: options, context: context) {
|
||||
context = result.context
|
||||
|
@ -118,7 +119,7 @@ public final class ImageManager : ObservableObject {
|
|||
// This callback is synchronzied
|
||||
manager.imageCache.containsImage(forKey: key, cacheType: .memory) { [unowned self] (cacheType) in
|
||||
if cacheType == .memory {
|
||||
self.manager.imageCache.queryImage(forKey: key, options: self.options, context: self.context) { [unowned self] (image, data, cacheType) in
|
||||
self.manager.imageCache.queryImage(forKey: key, options: options, context: context) { [unowned self] (image, data, cacheType) in
|
||||
self.image = image
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public struct WebImage : View {
|
|||
}
|
||||
self.imageManager = ImageManager(url: url, options: options, context: context)
|
||||
// this prefetch the memory cache of image, to immediately render it on screen
|
||||
// this solve the cause when `onAppear` not been called, for example, some transaction indetermite state :)
|
||||
// this solve the case when `onAppear` not been called, for example, some transaction indeterminate state, SwiftUI :)
|
||||
self.imageManager.prefetch()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue