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

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,6 +365,7 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
{renderTabs()}
</div>
<div className="image-container">
{image.visual_files.length > 0 && (
<ImageView
loop={image.visual_files[0].__typename == "VideoFile"}
autoPlay={image.visual_files[0].__typename == "VideoFile"}
@@ -375,6 +379,7 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
alt={title}
src={image.paths.image ?? ""}
/>
)}
</div>
</div>
);