Fix thumbnails

This commit is contained in:
Arkadiusz Fal 2022-12-11 14:00:46 +01:00
parent 5e0f13cace
commit e3daa738ce
2 changed files with 9 additions and 28 deletions

View File

@ -3,38 +3,18 @@ import SwiftUI
struct ThumbnailView: View {
var url: URL?
@ObservedObject private var imageManager = ImageManager()
private var thumbnails = ThumbnailsModel.shared
init(url: URL? = nil) {
self.url = url
}
@ObservedObject private var thumbnails = ThumbnailsModel.shared
var body: some View {
Group {
if imageManager.image != nil {
Group {
#if os(macOS)
Image(nsImage: imageManager.image!)
.resizable()
#else
Image(uiImage: imageManager.image!)
.resizable()
#endif
WebImage(url: url)
.resizable()
.onFailure { _ in
if let url {
thumbnails.insertUnloadable(url)
}
} else {
}
.placeholder {
Rectangle().fill(Color("PlaceholderColor"))
}
}
.onAppear {
guard let url else { return }
self.imageManager.setOnFailure { _ in
self.thumbnails.insertUnloadable(url)
}
self.imageManager.load(url: url)
}
.onDisappear { self.imageManager.cancel() }
}
}

View File

@ -52,6 +52,7 @@ struct VideoCell: View {
.contextMenu {
VideoContextMenuView(video: video)
}
.id(video.videoID)
}
private var thumbnailRoundingCornerRadius: Double {