From 9f3a94137c6593890292d4948642b22a6f895d5c Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 17 Dec 2022 14:38:21 +0100 Subject: [PATCH] Fix thumbnail view --- Shared/Videos/ThumbnailView.swift | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Shared/Videos/ThumbnailView.swift b/Shared/Videos/ThumbnailView.swift index ee2f01b0..f387fe58 100644 --- a/Shared/Videos/ThumbnailView.swift +++ b/Shared/Videos/ThumbnailView.swift @@ -7,13 +7,19 @@ struct ThumbnailView: View { private let thumbnails = ThumbnailsModel.shared var body: some View { - viewForThumbnailExtension + if url != nil { + viewForThumbnailExtension + } } var thumbnailExtension: String? { - guard let url else { return nil } - let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) - return urlComponents?.path.components(separatedBy: ".").last + guard let url, + let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return nil } + + let pathComponents = urlComponents.path.components(separatedBy: ".") + guard pathComponents.count > 1 else { return nil } + + return pathComponents.last } @ViewBuilder var viewForThumbnailExtension: some View { @@ -24,7 +30,7 @@ struct ThumbnailView: View { asyncImageIfAvailable } } else { - asyncImageIfAvailable + webImage } }