From c8320d4e20d00455cb6401331cf54616bceb4e4c Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Thu, 27 Jun 2024 23:08:56 +0800 Subject: [PATCH] Revert the wrong changes to fix the unit test --- Example/SDWebImageSwiftUIDemo/ContentView.swift | 2 ++ SDWebImageSwiftUI/Classes/AnimatedImage.swift | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Example/SDWebImageSwiftUIDemo/ContentView.swift b/Example/SDWebImageSwiftUIDemo/ContentView.swift index e1fc7a5..4cb0fa5 100644 --- a/Example/SDWebImageSwiftUIDemo/ContentView.swift +++ b/Example/SDWebImageSwiftUIDemo/ContentView.swift @@ -17,6 +17,7 @@ class UserSettings: ObservableObject { #endif } +#if !os(watchOS) struct ContentView4: View { var url = URL(string: "https://github.com/SDWebImage/SDWebImageSwiftUI/assets/97430818/72d27f90-e9d8-48d7-b144-82ada828a027")! var body: some View { @@ -27,6 +28,7 @@ struct ContentView4: View { .clipShape(RoundedRectangle(cornerRadius: 50, style: .continuous)) } } +#endif // Test Switching nil url struct ContentView3: View { diff --git a/SDWebImageSwiftUI/Classes/AnimatedImage.swift b/SDWebImageSwiftUI/Classes/AnimatedImage.swift index 193c9eb..6654372 100644 --- a/SDWebImageSwiftUI/Classes/AnimatedImage.swift +++ b/SDWebImageSwiftUI/Classes/AnimatedImage.swift @@ -309,8 +309,6 @@ public struct AnimatedImage : PlatformViewRepresentable { #endif context.coordinator.imageLoading.imageName = name view.wrapped.image = image - // Finished loading, sync - finishUpdateView(view, context: context, image: image) } private func updateViewForData(_ data: Data?, view: AnimatedImageViewWrapper, context: Context) { @@ -324,8 +322,6 @@ public struct AnimatedImage : PlatformViewRepresentable { } context.coordinator.imageLoading.imageData = data view.wrapped.image = image - // Finished loading, sync - finishUpdateView(view, context: context, image: image) } private func updateViewForURL(_ url: URL?, view: AnimatedImageViewWrapper, context: Context) { @@ -350,8 +346,6 @@ public struct AnimatedImage : PlatformViewRepresentable { setupIndicator(view, context: context) loadImage(view, context: context) } - // Finished loading, sync - finishUpdateView(view, context: context, image: view.wrapped.image) } func updateView(_ view: AnimatedImageViewWrapper, context: Context) { @@ -369,6 +363,9 @@ public struct AnimatedImage : PlatformViewRepresentable { break // impossible } + // Finished loading, sync + finishUpdateView(view, context: context, image: view.wrapped.image) + if let viewUpdateBlock = imageHandler.viewUpdateBlock { viewUpdateBlock(view.wrapped, context) }