From 5835a715888dd74181a3f72659dd114e1c40efa1 Mon Sep 17 00:00:00 2001 From: Maximilian Harz Date: Thu, 6 Feb 2025 12:38:06 +0100 Subject: [PATCH] Type item.gallery --- src/Components/Profile/Subcomponents/GalleryView.tsx | 9 ++++----- src/types/Item.d.ts | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Components/Profile/Subcomponents/GalleryView.tsx b/src/Components/Profile/Subcomponents/GalleryView.tsx index 7cf2bc37..affd8515 100644 --- a/src/Components/Profile/Subcomponents/GalleryView.tsx +++ b/src/Components/Profile/Subcomponents/GalleryView.tsx @@ -1,7 +1,3 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -/* eslint-disable @typescript-eslint/restrict-template-expressions */ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { useState } from 'react' import { RowsPhotoAlbum } from 'react-photo-album' import ReactLightbox from 'yet-another-react-lightbox' @@ -15,7 +11,7 @@ import type { Item } from '#types/Item' export const GalleryView = ({ item }: { item: Item }) => { const [index, setIndex] = useState(-1) const appState = useAppState() - const images = item.gallery.map((i, j) => { + const images = item.gallery?.map((i, j) => { return { src: appState.assetsApi.url + `${i.directus_files_id.id}.jpg`, width: i.directus_files_id.width, @@ -23,6 +19,9 @@ export const GalleryView = ({ item }: { item: Item }) => { index: j, } }) + + if (!images) throw new Error('GalleryView: images is undefined') + return (