Allow videos in posts, simplify post image view
This commit is contained in:
@ -79,6 +79,17 @@ final class LoadingContext {
|
||||
return nil
|
||||
}
|
||||
|
||||
func postMedia(_ imageId: String) -> FileResource? {
|
||||
guard let image = file(imageId) else {
|
||||
return nil
|
||||
}
|
||||
if image.type.isImage || image.type.isVideo {
|
||||
return image
|
||||
}
|
||||
error("Post Media \(imageId) is not an image or video")
|
||||
return nil
|
||||
}
|
||||
|
||||
func item(itemId: ItemId) -> Item? {
|
||||
switch itemId.type {
|
||||
case .post:
|
||||
|
@ -53,6 +53,16 @@ final class LocalizedPost: ObservableObject {
|
||||
}
|
||||
linkPreview.remove(file)
|
||||
}
|
||||
|
||||
// MARK: Images
|
||||
|
||||
var hasImages: Bool {
|
||||
images.contains { $0.type.isImage }
|
||||
}
|
||||
|
||||
var hasVideos: Bool {
|
||||
images.contains { $0.type.isVideo }
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Storage
|
||||
@ -65,7 +75,7 @@ extension LocalizedPost {
|
||||
title: data.title,
|
||||
text: data.text,
|
||||
lastModified: data.lastModifiedDate,
|
||||
images: data.images.compactMap(context.image),
|
||||
images: data.images.compactMap(context.postMedia),
|
||||
pageLinkText: data.pageLinkText,
|
||||
linkPreview: .init(context: context, data: data.linkPreview))
|
||||
}
|
||||
|
Reference in New Issue
Block a user