Improve "chapter list" render performance

affected components:
- ChapterList
- ReaderChapterList
This commit is contained in:
schroda
2025-01-12 19:08:46 +01:00
parent e7c3c8609e
commit 97dba923b4
4 changed files with 28 additions and 17 deletions

View File

@@ -38,6 +38,9 @@ import {
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
import { useMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts';
import { ChapterCard } from '@/modules/chapter/components/cards/ChapterCard.tsx';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { GetChaptersMangaQuery } from '@/lib/graphql/generated/graphql.ts';
import { GET_CHAPTERS_MANGA } from '@/lib/graphql/queries/ChapterQuery.ts';
type BaseProps = { onClose: () => void; selectable?: boolean };
@@ -50,7 +53,6 @@ type TChapter = ChapterIdInfo &
type SingleModeProps = {
chapter: TChapter;
allChapters: TChapter[];
handleSelection?: SelectableCollectionReturnType<TChapter['id']>['handleSelection'];
canBeDownloaded: boolean;
};
@@ -65,7 +67,6 @@ type Props =
export const ChapterActionMenuItems = ({
chapter,
allChapters,
handleSelection,
canBeDownloaded = false,
selectedChapters = [],
@@ -77,6 +78,16 @@ export const ChapterActionMenuItems = ({
const isSingleMode = !!chapter;
const { isDownloaded, isRead, isBookmarked } = chapter ?? {};
const mangaChaptersResponse = requestManager.useGetMangaChapters<GetChaptersMangaQuery>(
GET_CHAPTERS_MANGA,
chapter?.mangaId ?? -1,
{
skip: !chapter,
fetchPolicy: 'cache-only',
},
);
const allChapters = mangaChaptersResponse.data?.chapters.nodes ?? [];
const {
settings: { deleteChaptersWithBookmark },
} = useMetadataServerSettings();