Fix thumbnail view

This commit is contained in:
Arkadiusz Fal 2022-12-17 14:38:21 +01:00
parent 23b6edfcc5
commit 9f3a94137c

View File

@ -7,13 +7,19 @@ struct ThumbnailView: View {
private let thumbnails = ThumbnailsModel.shared private let thumbnails = ThumbnailsModel.shared
var body: some View { var body: some View {
if url != nil {
viewForThumbnailExtension viewForThumbnailExtension
} }
}
var thumbnailExtension: String? { var thumbnailExtension: String? {
guard let url else { return nil } guard let url,
let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return nil }
return urlComponents?.path.components(separatedBy: ".").last
let pathComponents = urlComponents.path.components(separatedBy: ".")
guard pathComponents.count > 1 else { return nil }
return pathComponents.last
} }
@ViewBuilder var viewForThumbnailExtension: some View { @ViewBuilder var viewForThumbnailExtension: some View {
@ -24,7 +30,7 @@ struct ThumbnailView: View {
asyncImageIfAvailable asyncImageIfAvailable
} }
} else { } else {
asyncImageIfAvailable webImage
} }
} }