From 900f570bb059a8ac43ba8ce570e9b2e18a815e50 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 5 Jul 2025 17:03:17 +0200 Subject: [PATCH] Consider only filtered chapters in chapter list actions --- src/modules/chapter/components/ChapterList.tsx | 7 +------ .../chapter/components/ChaptersToolbarMenu.tsx | 15 ++++++++------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/modules/chapter/components/ChapterList.tsx b/src/modules/chapter/components/ChapterList.tsx index 5eebeede..acad6db2 100644 --- a/src/modules/chapter/components/ChapterList.tsx +++ b/src/modules/chapter/components/ChapterList.tsx @@ -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 && ( diff --git a/src/modules/chapter/components/ChaptersToolbarMenu.tsx b/src/modules/chapter/components/ChaptersToolbarMenu.tsx index fb6a04f9..ce03f346 100644 --- a/src/modules/chapter/components/ChaptersToolbarMenu.tsx +++ b/src/modules/chapter/components/ChaptersToolbarMenu.tsx @@ -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; - 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 ( <> Chapters.markAsRead(unreadChapters, true, mangaId)} + onClick={() => Chapters.markAsRead(Chapters.getNonRead(chapters), true, mangaId)} color="inherit" >