2022-11-24 09:41:03 +01: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
|
2023-05-18 13:17:41 +02:00
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
2022-11-24 09:41:03 +01:00
|
|
|
|
|
|
|
|
import FilterList from '@mui/icons-material/FilterList';
|
2024-04-14 15:50:12 +02:00
|
|
|
import IconButton from '@mui/material/IconButton';
|
2024-09-17 03:40:55 +02:00
|
|
|
import { ComponentProps, useState } from 'react';
|
2026-01-10 19:45:02 +01:00
|
|
|
import { useLingui } from '@lingui/react/macro';
|
2025-08-16 02:48:46 +02:00
|
|
|
import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
|
2025-08-15 22:02:58 +02:00
|
|
|
import { LibraryOptionsPanel } from '@/features/library/components/LibraryOptionsPanel.tsx';
|
|
|
|
|
import { getCategoryMetadata } from '@/features/category/services/CategoryMetadata.ts';
|
2022-11-24 09:41:03 +01:00
|
|
|
|
2024-09-17 03:40:55 +02:00
|
|
|
export const LibraryToolbarMenu = ({
|
|
|
|
|
category,
|
|
|
|
|
}: {
|
|
|
|
|
category: ComponentProps<typeof LibraryOptionsPanel>['category'];
|
|
|
|
|
}) => {
|
2026-01-10 19:45:02 +01:00
|
|
|
const { t } = useLingui();
|
2023-11-05 17:22:29 +01:00
|
|
|
|
2022-11-24 09:41:03 +01:00
|
|
|
const [open, setOpen] = useState(false);
|
2025-05-03 13:59:21 +02:00
|
|
|
const options = getCategoryMetadata(category);
|
2024-03-29 16:55:07 +01:00
|
|
|
const active =
|
2024-09-16 11:35:55 +02:00
|
|
|
options.hasDownloadedChapters != null ||
|
|
|
|
|
options.hasUnreadChapters != null ||
|
2024-12-27 03:32:30 +01:00
|
|
|
options.hasReadChapters != null ||
|
2024-09-21 21:38:20 +02:00
|
|
|
options.hasBookmarkedChapters != null ||
|
|
|
|
|
options.hasDuplicateChapters != null ||
|
|
|
|
|
Object.values(options.hasStatus).some((hasStatus) => hasStatus != null) ||
|
2024-09-16 11:35:55 +02:00
|
|
|
Object.values(options.hasTrackerBinding).some((trackerFilterStatus) => trackerFilterStatus != null);
|
2022-11-24 09:41:03 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2026-01-10 19:45:02 +01:00
|
|
|
<CustomTooltip title={t`Settings`}>
|
2024-09-06 16:59:27 +02:00
|
|
|
<IconButton onClick={() => setOpen(!open)} color={active ? 'warning' : 'inherit'}>
|
2023-11-05 17:22:29 +01:00
|
|
|
<FilterList />
|
|
|
|
|
</IconButton>
|
2025-02-01 14:24:38 +01:00
|
|
|
</CustomTooltip>
|
2024-09-17 03:40:55 +02:00
|
|
|
<LibraryOptionsPanel category={category} open={open} onClose={() => setOpen(false)} />
|
2022-11-24 09:41:03 +01:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|