File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Sources/ComponentsKit/Components/Avatar Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ public struct SUAvatar: View {
77 /// A model that defines the appearance properties.
88 public var model : AvatarVM
99
10- @State private var loadedImage : UIImage ?
10+ @State private var loadedImage : ( url : URL , image : UIImage ) ?
1111
1212 // MARK: - Initialization
1313
@@ -26,7 +26,7 @@ public struct SUAvatar: View {
2626 switch source {
2727 case . remote:
2828 if let loadedImage {
29- Image ( uiImage: loadedImage)
29+ Image ( uiImage: loadedImage. image )
3030 . resizable ( )
3131 . transition ( . opacity)
3232 } else {
@@ -75,10 +75,13 @@ public struct SUAvatar: View {
7575 // MARK: - Helpers
7676
7777 private func downloadImage( url: URL ) {
78+ guard self . loadedImage? . url != url else { return }
79+
80+ self . loadedImage = nil
7881 Task { @MainActor in
79- let image = await ImageLoader . download ( url: url)
82+ guard let image = await ImageLoader . download ( url: url) else { return }
8083 withAnimation {
81- self . loadedImage = image
84+ self . loadedImage = ( url , image)
8285 }
8386 }
8487 }
You can’t perform that action at this time.
0 commit comments