Consider only filtered chapters in chapter list actions

This commit is contained in:
schroda
2025-07-05 17:03:17 +02:00
parent 99e5eb2dac
commit 900f570bb0
2 changed files with 9 additions and 13 deletions

View File

@@ -36,7 +36,6 @@ import { ChapterActionMenuItems } from '@/modules/chapter/components/actions/Cha
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
import { LoadingPlaceholder } from '@/modules/core/components/feedback/LoadingPlaceholder.tsx';
import { GET_CHAPTERS_MANGA } from '@/lib/graphql/queries/ChapterQuery.ts';
import { Mangas } from '@/modules/manga/services/Mangas.ts';
import { useNavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx';
import { useResizeObserver } from '@/modules/core/hooks/useResizeObserver.tsx';
import { MediaQuery } from '@/modules/core/utils/MediaQuery.tsx';
@@ -143,8 +142,6 @@ export const ChapterList = ({
const visibleChapters = useMemo(() => filterAndSortChapters(chapters, options), [chapters, options]);
const visibleChapterIds = useMemo(() => Chapters.getIds(visibleChapters), [visibleChapters]);
const areAllChaptersRead = Mangas.isFullyRead(manga);
const areAllChaptersDownloaded = Mangas.isFullyDownloaded(manga);
const missingChapterCount = useMemo(() => Chapters.getMissingCount(visibleChapters), [visibleChapters]);
const noChaptersFound = chapters.length === 0;
@@ -211,11 +208,9 @@ export const ChapterList = ({
{areNoItemsSelected && (
<ChaptersToolbarMenu
mangaId={manga.id}
areAllChaptersDownloaded={areAllChaptersDownloaded}
areAllChaptersRead={areAllChaptersRead}
options={options}
updateOption={updateOption}
unreadChapters={Chapters.getNonRead(chapters)}
chapters={visibleChapters}
scanlators={Chapters.getScanlators(chapters)}
excludeScanlators={options.excludedScanlators}
/>

View File

@@ -14,6 +14,7 @@ import PopupState, { bindMenu, bindTrigger } from 'material-ui-popup-state';
import Menu from '@mui/material/Menu';
import DownloadIcon from '@mui/icons-material/Download';
import DoneAllIcon from '@mui/icons-material/DoneAll';
import { useMemo } from 'react';
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
import { ChapterOptions } from '@/modules/chapter/components/ChapterOptions.tsx';
import { isFilterActive, updateChapterListOptions } from '@/modules/chapter/utils/ChapterList.util.tsx';
@@ -22,28 +23,25 @@ import {
ChapterDownloadInfo,
ChapterIdInfo,
ChapterListOptions,
ChapterReadInfo,
} from '@/modules/chapter/Chapter.types.ts';
import { ChaptersDownloadActionMenuItems } from '@/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx';
import { Chapters } from '@/modules/chapter/services/Chapters.ts';
interface IProps {
mangaId: number;
areAllChaptersRead: boolean;
areAllChaptersDownloaded: boolean;
options: ChapterListOptions;
updateOption: ReturnType<typeof updateChapterListOptions>;
unreadChapters: (ChapterIdInfo & ChapterDownloadInfo & ChapterBookmarkInfo)[];
chapters: (ChapterIdInfo & ChapterReadInfo & ChapterDownloadInfo & ChapterBookmarkInfo)[];
scanlators: string[];
excludeScanlators: string[];
}
export const ChaptersToolbarMenu = ({
mangaId,
areAllChaptersRead,
areAllChaptersDownloaded,
options,
updateOption,
unreadChapters,
chapters,
scanlators,
excludeScanlators,
}: IProps) => {
@@ -52,6 +50,9 @@ export const ChaptersToolbarMenu = ({
const [open, setOpen] = React.useState(false);
const isFiltered = isFilterActive(options);
const areAllChaptersRead = useMemo(() => chapters.every(Chapters.isRead), [chapters]);
const areAllChaptersDownloaded = useMemo(() => chapters.every(Chapters.isDownloaded), [chapters]);
return (
<>
<CustomTooltip
@@ -60,7 +61,7 @@ export const ChaptersToolbarMenu = ({
>
<IconButton
disabled={areAllChaptersRead}
onClick={() => Chapters.markAsRead(unreadChapters, true, mangaId)}
onClick={() => Chapters.markAsRead(Chapters.getNonRead(chapters), true, mangaId)}
color="inherit"
>
<DoneAllIcon />