Consider only filtered chapters in chapter list actions
This commit is contained in:
@@ -36,7 +36,6 @@ import { ChapterActionMenuItems } from '@/modules/chapter/components/actions/Cha
|
|||||||
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
|
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
|
||||||
import { LoadingPlaceholder } from '@/modules/core/components/feedback/LoadingPlaceholder.tsx';
|
import { LoadingPlaceholder } from '@/modules/core/components/feedback/LoadingPlaceholder.tsx';
|
||||||
import { GET_CHAPTERS_MANGA } from '@/lib/graphql/queries/ChapterQuery.ts';
|
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 { useNavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx';
|
||||||
import { useResizeObserver } from '@/modules/core/hooks/useResizeObserver.tsx';
|
import { useResizeObserver } from '@/modules/core/hooks/useResizeObserver.tsx';
|
||||||
import { MediaQuery } from '@/modules/core/utils/MediaQuery.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 visibleChapters = useMemo(() => filterAndSortChapters(chapters, options), [chapters, options]);
|
||||||
const visibleChapterIds = useMemo(() => Chapters.getIds(visibleChapters), [visibleChapters]);
|
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 missingChapterCount = useMemo(() => Chapters.getMissingCount(visibleChapters), [visibleChapters]);
|
||||||
|
|
||||||
const noChaptersFound = chapters.length === 0;
|
const noChaptersFound = chapters.length === 0;
|
||||||
@@ -211,11 +208,9 @@ export const ChapterList = ({
|
|||||||
{areNoItemsSelected && (
|
{areNoItemsSelected && (
|
||||||
<ChaptersToolbarMenu
|
<ChaptersToolbarMenu
|
||||||
mangaId={manga.id}
|
mangaId={manga.id}
|
||||||
areAllChaptersDownloaded={areAllChaptersDownloaded}
|
|
||||||
areAllChaptersRead={areAllChaptersRead}
|
|
||||||
options={options}
|
options={options}
|
||||||
updateOption={updateOption}
|
updateOption={updateOption}
|
||||||
unreadChapters={Chapters.getNonRead(chapters)}
|
chapters={visibleChapters}
|
||||||
scanlators={Chapters.getScanlators(chapters)}
|
scanlators={Chapters.getScanlators(chapters)}
|
||||||
excludeScanlators={options.excludedScanlators}
|
excludeScanlators={options.excludedScanlators}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import PopupState, { bindMenu, bindTrigger } from 'material-ui-popup-state';
|
|||||||
import Menu from '@mui/material/Menu';
|
import Menu from '@mui/material/Menu';
|
||||||
import DownloadIcon from '@mui/icons-material/Download';
|
import DownloadIcon from '@mui/icons-material/Download';
|
||||||
import DoneAllIcon from '@mui/icons-material/DoneAll';
|
import DoneAllIcon from '@mui/icons-material/DoneAll';
|
||||||
|
import { useMemo } from 'react';
|
||||||
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
|
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
|
||||||
import { ChapterOptions } from '@/modules/chapter/components/ChapterOptions.tsx';
|
import { ChapterOptions } from '@/modules/chapter/components/ChapterOptions.tsx';
|
||||||
import { isFilterActive, updateChapterListOptions } from '@/modules/chapter/utils/ChapterList.util.tsx';
|
import { isFilterActive, updateChapterListOptions } from '@/modules/chapter/utils/ChapterList.util.tsx';
|
||||||
@@ -22,28 +23,25 @@ import {
|
|||||||
ChapterDownloadInfo,
|
ChapterDownloadInfo,
|
||||||
ChapterIdInfo,
|
ChapterIdInfo,
|
||||||
ChapterListOptions,
|
ChapterListOptions,
|
||||||
|
ChapterReadInfo,
|
||||||
} from '@/modules/chapter/Chapter.types.ts';
|
} from '@/modules/chapter/Chapter.types.ts';
|
||||||
import { ChaptersDownloadActionMenuItems } from '@/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx';
|
import { ChaptersDownloadActionMenuItems } from '@/modules/chapter/components/actions/ChaptersDownloadActionMenuItems.tsx';
|
||||||
import { Chapters } from '@/modules/chapter/services/Chapters.ts';
|
import { Chapters } from '@/modules/chapter/services/Chapters.ts';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
mangaId: number;
|
mangaId: number;
|
||||||
areAllChaptersRead: boolean;
|
|
||||||
areAllChaptersDownloaded: boolean;
|
|
||||||
options: ChapterListOptions;
|
options: ChapterListOptions;
|
||||||
updateOption: ReturnType<typeof updateChapterListOptions>;
|
updateOption: ReturnType<typeof updateChapterListOptions>;
|
||||||
unreadChapters: (ChapterIdInfo & ChapterDownloadInfo & ChapterBookmarkInfo)[];
|
chapters: (ChapterIdInfo & ChapterReadInfo & ChapterDownloadInfo & ChapterBookmarkInfo)[];
|
||||||
scanlators: string[];
|
scanlators: string[];
|
||||||
excludeScanlators: string[];
|
excludeScanlators: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChaptersToolbarMenu = ({
|
export const ChaptersToolbarMenu = ({
|
||||||
mangaId,
|
mangaId,
|
||||||
areAllChaptersRead,
|
|
||||||
areAllChaptersDownloaded,
|
|
||||||
options,
|
options,
|
||||||
updateOption,
|
updateOption,
|
||||||
unreadChapters,
|
chapters,
|
||||||
scanlators,
|
scanlators,
|
||||||
excludeScanlators,
|
excludeScanlators,
|
||||||
}: IProps) => {
|
}: IProps) => {
|
||||||
@@ -52,6 +50,9 @@ export const ChaptersToolbarMenu = ({
|
|||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
const isFiltered = isFilterActive(options);
|
const isFiltered = isFilterActive(options);
|
||||||
|
|
||||||
|
const areAllChaptersRead = useMemo(() => chapters.every(Chapters.isRead), [chapters]);
|
||||||
|
const areAllChaptersDownloaded = useMemo(() => chapters.every(Chapters.isDownloaded), [chapters]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CustomTooltip
|
<CustomTooltip
|
||||||
@@ -60,7 +61,7 @@ export const ChaptersToolbarMenu = ({
|
|||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={areAllChaptersRead}
|
disabled={areAllChaptersRead}
|
||||||
onClick={() => Chapters.markAsRead(unreadChapters, true, mangaId)}
|
onClick={() => Chapters.markAsRead(Chapters.getNonRead(chapters), true, mangaId)}
|
||||||
color="inherit"
|
color="inherit"
|
||||||
>
|
>
|
||||||
<DoneAllIcon />
|
<DoneAllIcon />
|
||||||
|
|||||||
Reference in New Issue
Block a user