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:
@@ -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,24 +221,24 @@ 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,
|
messageExtra,
|
||||||
messageExtra,
|
hasNextPage,
|
||||||
hasNextPage,
|
loadMore,
|
||||||
loadMore,
|
gridLayout,
|
||||||
gridLayout,
|
horizontal,
|
||||||
horizontal,
|
noFaces,
|
||||||
noFaces,
|
inLibraryIndicator,
|
||||||
inLibraryIndicator,
|
isSelectModeActive,
|
||||||
isSelectModeActive,
|
selectedMangaIds,
|
||||||
selectedMangaIds,
|
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}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user