diff --git a/src/components/manga/ChapterList.tsx b/src/components/manga/ChapterList.tsx index 1b80b186..4fd10c4a 100644 --- a/src/components/manga/ChapterList.tsx +++ b/src/components/manga/ChapterList.tsx @@ -12,6 +12,8 @@ import React, { ComponentProps, useMemo, useState } from 'react'; import { Virtuoso } from 'react-virtuoso'; import { useTranslation } from 'react-i18next'; import Checkbox from '@mui/material/Checkbox'; +import IconButton from '@mui/material/IconButton'; +import DownloadIcon from '@mui/icons-material/Download'; import { TChapter, TManga, TranslationKey } from '@/typings'; import { requestManager } from '@/lib/requests/RequestManager.ts'; import { ChapterCard } from '@/components/manga/ChapterCard'; @@ -111,6 +113,8 @@ export const ChapterList: React.FC = ({ manga, isRefreshing }) => { const areAllChaptersSelected = selection?.length === chapters.length; const areNoneChaptersSelected = !selection; + const areAllChaptersDownloaded = manga.downloadCount === manga.chapters.totalCount; + const handleSelection = (index: number) => { const chapter = visibleChapters[index]; if (!chapter) return; @@ -141,7 +145,26 @@ export const ChapterList: React.FC = ({ manga, isRefreshing }) => { const handleFabAction: ComponentProps['onAction'] = (action, actionChapters) => { if (actionChapters.length === 0) return; - const chapterIds = actionChapters.map(({ chapter }) => chapter.id); + const chapterIds = actionChapters + .filter(({ chapter }) => { + switch (action) { + case 'download': + return !chapter.isDownloaded; + case 'delete': + return chapter.isDownloaded; + case 'bookmark': + return !chapter.isBookmarked; + case 'unbookmark': + return chapter.isBookmarked; + case 'mark_as_read': + return !chapter.isRead; + case 'mark_as_unread': + return chapter.isRead; + default: + throw new Error(`ChapterList::handleFabAction: unknown action "${action}"`); + } + }) + .map(({ chapter }) => chapter.id); let actionPromise: Promise; @@ -245,6 +268,14 @@ export const ChapterList: React.FC = ({ manga, isRefreshing }) => { + + handleFabAction('download', chaptersWithMeta)} + > + + +