2021-10-29 20:11:23 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-12-25 21:37:45 +01:00
|
|
|
import React, { useEffect } from 'react';
|
2022-04-07 12:53:14 +02:00
|
|
|
import { StringParam, useQueryParam } from 'use-query-params';
|
2023-03-23 13:59:32 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-12-25 21:37:45 +01:00
|
|
|
import { TManga } from '@/typings';
|
2023-06-05 01:42:39 +02:00
|
|
|
import { useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext';
|
2023-12-25 21:37:45 +01:00
|
|
|
import { IMangaGridProps, MangaGrid } from '@/components/MangaGrid';
|
2021-10-29 20:11:23 +02:00
|
|
|
|
2023-12-25 21:37:45 +01:00
|
|
|
interface LibraryMangaGridProps
|
|
|
|
|
extends Required<Pick<IMangaGridProps, 'isSelectModeActive' | 'selectedMangaIds' | 'handleSelection'>> {
|
2023-10-15 16:03:08 +02:00
|
|
|
mangas: TManga[];
|
2023-12-25 21:37:45 +01:00
|
|
|
showFilteredOutMessage: boolean;
|
2023-02-12 20:43:41 +05:30
|
|
|
isLoading: boolean;
|
|
|
|
|
message?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 21:37:45 +01:00
|
|
|
export const LibraryMangaGrid: React.FC<LibraryMangaGridProps> = ({
|
|
|
|
|
mangas,
|
|
|
|
|
showFilteredOutMessage,
|
|
|
|
|
isLoading,
|
|
|
|
|
message,
|
|
|
|
|
isSelectModeActive,
|
|
|
|
|
selectedMangaIds,
|
|
|
|
|
handleSelection,
|
|
|
|
|
}) => {
|
2023-03-23 13:59:32 +01:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2022-04-07 12:53:14 +02:00
|
|
|
const [query] = useQueryParam('query', StringParam);
|
2022-11-24 09:41:03 +01:00
|
|
|
const { options } = useLibraryOptionsContext();
|
|
|
|
|
const { unread, downloaded } = options;
|
2023-02-12 20:43:41 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
2023-05-18 13:24:34 +02:00
|
|
|
window.scrollTo(0, 0);
|
2023-10-04 22:34:32 +02:00
|
|
|
}, [query, unread, downloaded]);
|
2021-10-29 20:11:23 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<MangaGrid
|
2023-12-25 21:37:45 +01:00
|
|
|
mangas={mangas}
|
2021-10-29 20:11:23 +02:00
|
|
|
isLoading={isLoading}
|
2023-06-17 16:50:17 +02:00
|
|
|
hasNextPage={false}
|
|
|
|
|
loadMore={() => undefined}
|
2023-03-23 13:59:32 +01:00
|
|
|
message={showFilteredOutMessage ? t('library.error.label.no_matches') : message}
|
2022-03-06 16:45:25 +00:00
|
|
|
gridLayout={options.gridLayout}
|
2023-12-25 21:37:45 +01:00
|
|
|
isSelectModeActive={isSelectModeActive}
|
|
|
|
|
selectedMangaIds={selectedMangaIds}
|
|
|
|
|
handleSelection={handleSelection}
|
2021-10-29 20:11:23 +02:00
|
|
|
/>
|
|
|
|
|
);
|
2022-11-24 21:04:30 +01:00
|
|
|
};
|