Naming it as `isSuccess` to match what it check

This commit is contained in:
DreamPiggy 2019-11-02 19:03:20 +08:00
parent 57ed6ef5d1
commit e7c6931707
2 changed files with 4 additions and 4 deletions

View File

@ -16,7 +16,7 @@ class ImageManager : ObservableObject {
var manager = SDWebImageManager.shared
weak var currentOperation: SDWebImageOperation? = nil
var isFinished: Bool = false // true means request end, load() do nothing
var isSuccess: Bool = false // true means request for this URL is ended forever, load() do nothing
var isIncremental: Bool = false // true means during incremental loading
var url: URL?
@ -70,7 +70,7 @@ class ImageManager : ObservableObject {
self.isLoading = false
self.progress = 1
if let image = image {
self.isFinished = true
self.isSuccess = true
self.successBlock?(image, cacheType)
} else {
self.failureBlock?(error ?? NSError())

View File

@ -55,14 +55,14 @@ public struct WebImage : View {
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.onAppear {
guard self.retryOnAppear else { return }
if !self.imageManager.isFinished {
if !self.imageManager.isSuccess {
self.imageManager.load()
}
}
.onDisappear {
guard self.cancelOnDisappear else { return }
// When using prorgessive loading, the previous partial image will cause onDisappear. Filter this case
if !self.imageManager.isFinished && !self.imageManager.isIncremental {
if !self.imageManager.isSuccess && !self.imageManager.isIncremental {
self.imageManager.cancel()
}
}