Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Naming it as isSuccess to match what it check
  • Loading branch information
dreampiggy committed Nov 2, 2019
commit e7c69317070c95ce2448692eb3d6da811aa4aeee
4 changes: 2 additions & 2 deletions SDWebImageSwiftUI/Classes/ImageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions SDWebImageSwiftUI/Classes/WebImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down