Fix UI error when image has no files (#5325)

This commit is contained in:
WithoutPants 2024-10-02 09:58:48 +10:00 committed by GitHub
parent 93a2ee1277
commit 76a5b2a06a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 14 deletions

View File

@ -279,7 +279,10 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
);
const title = objectTitle(image);
const ImageView = isVideo(image.visual_files[0]) ? "video" : "img";
const ImageView =
image.visual_files.length > 0 && isVideo(image.visual_files[0])
? "video"
: "img";
const resolution = useMemo(() => {
return file?.width && file?.height
@ -362,19 +365,21 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
{renderTabs()}
</div>
<div className="image-container">
<ImageView
loop={image.visual_files[0].__typename == "VideoFile"}
autoPlay={image.visual_files[0].__typename == "VideoFile"}
controls={image.visual_files[0].__typename == "VideoFile"}
className="m-sm-auto no-gutter image-image"
style={
image.visual_files[0].__typename == "VideoFile"
? { width: "100%", height: "100%" }
: {}
}
alt={title}
src={image.paths.image ?? ""}
/>
{image.visual_files.length > 0 && (
<ImageView
loop={image.visual_files[0].__typename == "VideoFile"}
autoPlay={image.visual_files[0].__typename == "VideoFile"}
controls={image.visual_files[0].__typename == "VideoFile"}
className="m-sm-auto no-gutter image-image"
style={
image.visual_files[0].__typename == "VideoFile"
? { width: "100%", height: "100%" }
: {}
}
alt={title}
src={image.paths.image ?? ""}
/>
)}
</div>
</div>
);