From 93e95c0a8fe805858830594345c773222160648f Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:00:37 +0200 Subject: [PATCH] Show "no mangas found" message by default The non-null assertion operator was incorrectly used since "message" could be potentially undefined --- src/components/MangaGrid.tsx | 44 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/components/MangaGrid.tsx b/src/components/MangaGrid.tsx index 43cde7af..2f6cca07 100644 --- a/src/components/MangaGrid.tsx +++ b/src/components/MangaGrid.tsx @@ -11,6 +11,7 @@ import Grid, { GridTypeMap } from '@mui/material/Grid'; import Box from '@mui/material/Box'; import { GridItemProps, GridStateSnapshot, VirtuosoGrid } from 'react-virtuoso'; import { useLocation } from 'react-router-dom'; +import { useTranslation } from 'react-i18next'; import { EmptyViewAbsoluteCentered } from '@/components/util/EmptyViewAbsoluteCentered.tsx'; import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder'; import { MangaCard } from '@/components/MangaCard'; @@ -220,24 +221,24 @@ export interface IMangaGridProps noFaces?: boolean | undefined; } -export const MangaGrid: React.FC = (props) => { - const { - mangas, - isLoading, - message, - messageExtra, - hasNextPage, - loadMore, - gridLayout, - horizontal, - noFaces, - inLibraryIndicator, - isSelectModeActive, - selectedMangaIds, - handleSelection, - mode, - retry, - } = props; +export const MangaGrid: React.FC = ({ + mangas, + isLoading, + message, + messageExtra, + hasNextPage, + loadMore, + gridLayout, + horizontal, + noFaces, + inLibraryIndicator, + isSelectModeActive, + selectedMangaIds, + handleSelection, + mode, + retry, +}) => { + const { t } = useTranslation(); const gridRef = useRef(null); @@ -315,7 +316,12 @@ export const MangaGrid: React.FC = (props) => { const hasNoItems = !isLoading && mangas.length === 0; if (hasNoItems) { return ( - + ); }