diff --git a/SodaLive/Sources/Chat/Character/Banner/AutoSlideCharacterBannerView.swift b/SodaLive/Sources/Chat/Character/Banner/AutoSlideCharacterBannerView.swift index ad04973..406f7e5 100644 --- a/SodaLive/Sources/Chat/Character/Banner/AutoSlideCharacterBannerView.swift +++ b/SodaLive/Sources/Chat/Character/Banner/AutoSlideCharacterBannerView.swift @@ -79,11 +79,10 @@ private struct AutoSlideCharacterBannerPage: View { let width: CGFloat let height: CGFloat let onTap: (CharacterBannerResponse) -> Void - @State private var boundURL: URL? var body: some View { Group { - if let boundURL { + if let boundURL = URL(string: item.imageUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? item.imageUrl){ DownsampledKFImage( url: boundURL, size: CGSize(width: width, height: height) @@ -96,14 +95,5 @@ private struct AutoSlideCharacterBannerPage: View { } .contentShape(Rectangle()) .onTapGesture { onTap(item) } - .onAppear { - let encoded = item.imageUrl.addingPercentEncoding( - withAllowedCharacters: .urlQueryAllowed - ) ?? item.imageUrl - boundURL = URL(string: encoded) - } - .onDisappear { - boundURL = nil - } } } diff --git a/SodaLive/Sources/Content/Main/Banner/ContentMainBannerView.swift b/SodaLive/Sources/Content/Main/Banner/ContentMainBannerView.swift index 89b9052..de44e6e 100644 --- a/SodaLive/Sources/Content/Main/Banner/ContentMainBannerView.swift +++ b/SodaLive/Sources/Content/Main/Banner/ContentMainBannerView.swift @@ -82,11 +82,10 @@ private struct ContentMainBannerPage: View { let item: GetAudioContentBannerResponse let width: CGFloat let height: CGFloat - @State private var boundURL: URL? var body: some View { Group { - if let boundURL { + if let boundURL = URL(string: item.thumbnailImageUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? item.thumbnailImageUrl) { KFImage(boundURL) .cancelOnDisappear(true) .downsampling(size: CGSize(width: width, height: height)) @@ -118,15 +117,6 @@ private struct ContentMainBannerPage: View { } } } - .onAppear { - let urlString = item.thumbnailImageUrl.addingPercentEncoding( - withAllowedCharacters: .urlQueryAllowed - ) ?? item.thumbnailImageUrl - boundURL = URL(string: urlString) - } - .onDisappear { - boundURL = nil - } } } diff --git a/SodaLive/Sources/Content/Main/V2/ContentMainBannerViewV2.swift b/SodaLive/Sources/Content/Main/V2/ContentMainBannerViewV2.swift index 15da358..6cdf67d 100644 --- a/SodaLive/Sources/Content/Main/V2/ContentMainBannerViewV2.swift +++ b/SodaLive/Sources/Content/Main/V2/ContentMainBannerViewV2.swift @@ -107,11 +107,10 @@ struct ContentMainBannerImageView: View { let width: CGFloat let height: CGFloat let item: GetAudioContentBannerResponse - @State private var boundURL: URL? var body: some View { Group { - if let boundURL { + if let boundURL = URL(string: url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url) { DownsampledKFImage( url: boundURL, size: CGSize(width: width, height: height) @@ -138,12 +137,5 @@ struct ContentMainBannerImageView: View { } } } - .onAppear { - let encoded = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url - boundURL = URL(string: encoded) - } - .onDisappear { - boundURL = nil - } } } diff --git a/SodaLive/Sources/Content/Series/Main/Home/SeriesMainHomeBannerView.swift b/SodaLive/Sources/Content/Series/Main/Home/SeriesMainHomeBannerView.swift index dff2950..c34269c 100644 --- a/SodaLive/Sources/Content/Series/Main/Home/SeriesMainHomeBannerView.swift +++ b/SodaLive/Sources/Content/Series/Main/Home/SeriesMainHomeBannerView.swift @@ -80,11 +80,10 @@ struct SeriesMainHomeBannerImageView: View { let url: String let width: CGFloat let height: CGFloat - @State private var boundURL: URL? var body: some View { Group { - if let boundURL { + if let boundURL = URL(string: url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url) { DownsampledKFImage( url: boundURL, size: CGSize(width: width, height: height) @@ -97,13 +96,6 @@ struct SeriesMainHomeBannerImageView: View { } } .contentShape(Rectangle()) - .onAppear { - let encoded = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url - boundURL = URL(string: encoded) - } - .onDisappear { - boundURL = nil - } } } diff --git a/SodaLive/Sources/Live/EventBanner/SectionEventBannerView.swift b/SodaLive/Sources/Live/EventBanner/SectionEventBannerView.swift index 0c43cfb..4513713 100644 --- a/SodaLive/Sources/Live/EventBanner/SectionEventBannerView.swift +++ b/SodaLive/Sources/Live/EventBanner/SectionEventBannerView.swift @@ -77,11 +77,10 @@ private struct SectionEventBannerPage: View { let width: CGFloat let height: CGFloat let token: String - @State private var boundURL: URL? var body: some View { Group { - if let boundURL { + if let boundURL = URL(string: item.thumbnailImageUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? item.thumbnailImageUrl) { KFImage(boundURL) .cancelOnDisappear(true) .downsampling(size: CGSize(width: width, height: height)) @@ -108,14 +107,5 @@ private struct SectionEventBannerPage: View { AppState.shared.setAppStep(step: .login) } } - .onAppear { - let urlString = item.thumbnailImageUrl.addingPercentEncoding( - withAllowedCharacters: .urlQueryAllowed - ) ?? item.thumbnailImageUrl - boundURL = URL(string: urlString) - } - .onDisappear { - boundURL = nil - } } }