Revert the wrong changes to fix the unit test

This commit is contained in:
DreamPiggy 2024-06-27 23:08:56 +08:00
parent 3340ea4ed4
commit c8320d4e20
2 changed files with 5 additions and 6 deletions

View File

@ -17,6 +17,7 @@ class UserSettings: ObservableObject {
#endif #endif
} }
#if !os(watchOS)
struct ContentView4: View { struct ContentView4: View {
var url = URL(string: "https://github.com/SDWebImage/SDWebImageSwiftUI/assets/97430818/72d27f90-e9d8-48d7-b144-82ada828a027")! var url = URL(string: "https://github.com/SDWebImage/SDWebImageSwiftUI/assets/97430818/72d27f90-e9d8-48d7-b144-82ada828a027")!
var body: some View { var body: some View {
@ -27,6 +28,7 @@ struct ContentView4: View {
.clipShape(RoundedRectangle(cornerRadius: 50, style: .continuous)) .clipShape(RoundedRectangle(cornerRadius: 50, style: .continuous))
} }
} }
#endif
// Test Switching nil url // Test Switching nil url
struct ContentView3: View { struct ContentView3: View {

View File

@ -309,8 +309,6 @@ public struct AnimatedImage : PlatformViewRepresentable {
#endif #endif
context.coordinator.imageLoading.imageName = name context.coordinator.imageLoading.imageName = name
view.wrapped.image = image view.wrapped.image = image
// Finished loading, sync
finishUpdateView(view, context: context, image: image)
} }
private func updateViewForData(_ data: Data?, view: AnimatedImageViewWrapper, context: Context) { private func updateViewForData(_ data: Data?, view: AnimatedImageViewWrapper, context: Context) {
@ -324,8 +322,6 @@ public struct AnimatedImage : PlatformViewRepresentable {
} }
context.coordinator.imageLoading.imageData = data context.coordinator.imageLoading.imageData = data
view.wrapped.image = image view.wrapped.image = image
// Finished loading, sync
finishUpdateView(view, context: context, image: image)
} }
private func updateViewForURL(_ url: URL?, view: AnimatedImageViewWrapper, context: Context) { private func updateViewForURL(_ url: URL?, view: AnimatedImageViewWrapper, context: Context) {
@ -350,8 +346,6 @@ public struct AnimatedImage : PlatformViewRepresentable {
setupIndicator(view, context: context) setupIndicator(view, context: context)
loadImage(view, context: context) loadImage(view, context: context)
} }
// Finished loading, sync
finishUpdateView(view, context: context, image: view.wrapped.image)
} }
func updateView(_ view: AnimatedImageViewWrapper, context: Context) { func updateView(_ view: AnimatedImageViewWrapper, context: Context) {
@ -369,6 +363,9 @@ public struct AnimatedImage : PlatformViewRepresentable {
break // impossible break // impossible
} }
// Finished loading, sync
finishUpdateView(view, context: context, image: view.wrapped.image)
if let viewUpdateBlock = imageHandler.viewUpdateBlock { if let viewUpdateBlock = imageHandler.viewUpdateBlock {
viewUpdateBlock(view.wrapped, context) viewUpdateBlock(view.wrapped, context)
} }