Show "no mangas found" message by default

The non-null assertion operator was incorrectly used since "message" could be potentially undefined
This commit is contained in:
schroda
2024-04-29 15:00:37 +02:00
parent bcccbda00c
commit 93e95c0a8f

View File

@@ -11,6 +11,7 @@ import Grid, { GridTypeMap } from '@mui/material/Grid';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import { GridItemProps, GridStateSnapshot, VirtuosoGrid } from 'react-virtuoso'; import { GridItemProps, GridStateSnapshot, VirtuosoGrid } from 'react-virtuoso';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { EmptyViewAbsoluteCentered } from '@/components/util/EmptyViewAbsoluteCentered.tsx'; import { EmptyViewAbsoluteCentered } from '@/components/util/EmptyViewAbsoluteCentered.tsx';
import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder'; import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder';
import { MangaCard } from '@/components/MangaCard'; import { MangaCard } from '@/components/MangaCard';
@@ -220,8 +221,7 @@ export interface IMangaGridProps
noFaces?: boolean | undefined; noFaces?: boolean | undefined;
} }
export const MangaGrid: React.FC<IMangaGridProps> = (props) => { export const MangaGrid: React.FC<IMangaGridProps> = ({
const {
mangas, mangas,
isLoading, isLoading,
message, message,
@@ -237,7 +237,8 @@ export const MangaGrid: React.FC<IMangaGridProps> = (props) => {
handleSelection, handleSelection,
mode, mode,
retry, retry,
} = props; }) => {
const { t } = useTranslation();
const gridRef = useRef<HTMLDivElement>(null); const gridRef = useRef<HTMLDivElement>(null);
@@ -315,7 +316,12 @@ export const MangaGrid: React.FC<IMangaGridProps> = (props) => {
const hasNoItems = !isLoading && mangas.length === 0; const hasNoItems = !isLoading && mangas.length === 0;
if (hasNoItems) { if (hasNoItems) {
return ( return (
<EmptyViewAbsoluteCentered noFaces={noFaces} message={message!} messageExtra={messageExtra} retry={retry} /> <EmptyViewAbsoluteCentered
noFaces={noFaces}
message={message ?? t('manga.error.label.no_mangas_found')}
messageExtra={messageExtra}
retry={retry}
/>
); );
} }