diff --git a/src/components/manga/ChapterList.tsx b/src/components/manga/ChapterList.tsx index e6a10cae5e..94c5df4160 100644 --- a/src/components/manga/ChapterList.tsx +++ b/src/components/manga/ChapterList.tsx @@ -8,7 +8,7 @@ import { Button, CircularProgress, Stack, styled } from '@mui/material'; import Typography from '@mui/material/Typography'; -import React, { ComponentProps, useEffect, useMemo, useRef, useState } from 'react'; +import React, { ComponentProps, useMemo, useState } from 'react'; import { Virtuoso } from 'react-virtuoso'; import { useTranslation } from 'react-i18next'; import { TChapter, TManga, TranslationKey } from '@/typings'; @@ -83,37 +83,15 @@ export const ChapterList: React.FC = ({ manga, isRefreshing }) => { const { t } = useTranslation(); const [selection, setSelection] = useState(null); - const prevQueueRef = useRef(); const { data: downloaderData } = requestManager.useDownloadSubscription(); const queue = (downloaderData?.downloadChanged.queue as DownloadType[]) ?? []; const [options, dispatch] = useChapterOptions(manga.id); - const { data: chaptersData, loading: isLoading, refetch } = requestManager.useGetMangaChapters(manga.id); + const { data: chaptersData, loading: isLoading } = requestManager.useGetMangaChapters(manga.id); const chapters = useMemo(() => chaptersData?.chapters.nodes ?? [], [chaptersData?.chapters.nodes]); const { settings: metadataServerSettings } = useMetadataServerSettings(); - useEffect(() => { - if (prevQueueRef.current && queue) { - const prevQueue = prevQueueRef.current; - const changedDownloads = queue.filter((cd) => { - const prevChapterDownload = prevQueue.find( - (pcd) => - cd.chapter.sourceOrder === pcd.chapter.sourceOrder && - cd.chapter.manga.id === pcd.chapter.manga.id, - ); - if (!prevChapterDownload) return true; - return cd.state !== prevChapterDownload.state; - }); - - if (changedDownloads.length > 0 || prevQueue?.length !== queue.length) { - refetch(); - } - } - - prevQueueRef.current = queue; - }, [queue]); - const visibleChapters = useMemo(() => filterAndSortChapters(chapters, options), [chapters, options]); const nextChapterIndexToRead = (manga.lastReadChapter?.sourceOrder ?? 0) + 1; diff --git a/src/lib/graphql/Fragments.ts b/src/lib/graphql/Fragments.ts index 48f5baf1fd..98e2d0264c 100644 --- a/src/lib/graphql/Fragments.ts +++ b/src/lib/graphql/Fragments.ts @@ -322,9 +322,11 @@ export const FULL_DOWNLOAD_STATUS = gql` id name sourceOrder + isDownloaded manga { id title + downloadCount } } progress diff --git a/src/lib/graphql/generated/graphql.ts b/src/lib/graphql/generated/graphql.ts index 0092e425ba..f893e5f22f 100644 --- a/src/lib/graphql/generated/graphql.ts +++ b/src/lib/graphql/generated/graphql.ts @@ -2137,7 +2137,7 @@ export type UpdaterMangaFieldsFragment = { __typename?: 'MangaType', id: number, export type FullExtensionFieldsFragment = { __typename?: 'ExtensionType', apkName: string, hasUpdate: boolean, iconUrl: string, isInstalled: boolean, isNsfw: boolean, isObsolete: boolean, lang: string, name: string, pkgName: string, versionCode: number, versionName: string }; -export type FullDownloadStatusFragment = { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> }; +export type FullDownloadStatusFragment = { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> }; export type PartialUpdaterStatusFragment = { __typename?: 'UpdateStatus', isRunning: boolean }; @@ -2285,7 +2285,7 @@ export type ClearDownloaderMutationVariables = Exact<{ }>; -export type ClearDownloaderMutation = { __typename?: 'Mutation', clearDownloader: { __typename?: 'ClearDownloaderPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> } } }; +export type ClearDownloaderMutation = { __typename?: 'Mutation', clearDownloader: { __typename?: 'ClearDownloaderPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> } } }; export type DeleteDownloadedChapterMutationVariables = Exact<{ input: DeleteDownloadedChapterInput; @@ -2306,35 +2306,35 @@ export type DequeueChapterDownloadMutationVariables = Exact<{ }>; -export type DequeueChapterDownloadMutation = { __typename?: 'Mutation', dequeueChapterDownload: { __typename?: 'DequeueChapterDownloadPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> } } }; +export type DequeueChapterDownloadMutation = { __typename?: 'Mutation', dequeueChapterDownload: { __typename?: 'DequeueChapterDownloadPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> } } }; export type DequeueChapterDownloadsMutationVariables = Exact<{ input: DequeueChapterDownloadsInput; }>; -export type DequeueChapterDownloadsMutation = { __typename?: 'Mutation', dequeueChapterDownloads: { __typename?: 'DequeueChapterDownloadsPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> } } }; +export type DequeueChapterDownloadsMutation = { __typename?: 'Mutation', dequeueChapterDownloads: { __typename?: 'DequeueChapterDownloadsPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> } } }; export type EnqueueChapterDownloadMutationVariables = Exact<{ input: EnqueueChapterDownloadInput; }>; -export type EnqueueChapterDownloadMutation = { __typename?: 'Mutation', enqueueChapterDownload: { __typename?: 'EnqueueChapterDownloadPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> } } }; +export type EnqueueChapterDownloadMutation = { __typename?: 'Mutation', enqueueChapterDownload: { __typename?: 'EnqueueChapterDownloadPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> } } }; export type EnqueueChapterDownloadsMutationVariables = Exact<{ input: EnqueueChapterDownloadsInput; }>; -export type EnqueueChapterDownloadsMutation = { __typename?: 'Mutation', enqueueChapterDownloads: { __typename?: 'EnqueueChapterDownloadsPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> } } }; +export type EnqueueChapterDownloadsMutation = { __typename?: 'Mutation', enqueueChapterDownloads: { __typename?: 'EnqueueChapterDownloadsPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> } } }; export type ReorderChapterDownloadMutationVariables = Exact<{ input: ReorderChapterDownloadInput; }>; -export type ReorderChapterDownloadMutation = { __typename?: 'Mutation', reorderChapterDownload: { __typename?: 'ReorderChapterDownloadPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> } } }; +export type ReorderChapterDownloadMutation = { __typename?: 'Mutation', reorderChapterDownload: { __typename?: 'ReorderChapterDownloadPayload', clientMutationId?: string | null, downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> } } }; export type StartDownloaderMutationVariables = Exact<{ input?: InputMaybe; @@ -2584,7 +2584,7 @@ export type GetChaptersQuery = { __typename?: 'Query', chapters: { __typename?: export type GetDownloadStatusQueryVariables = Exact<{ [key: string]: never; }>; -export type GetDownloadStatusQuery = { __typename?: 'Query', downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> } }; +export type GetDownloadStatusQuery = { __typename?: 'Query', downloadStatus: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> } }; export type GetExtensionQueryVariables = Exact<{ pkgName: Scalars['String']['input']; @@ -2702,7 +2702,7 @@ export type GetLastUpdateTimestampQuery = { __typename?: 'Query', lastUpdateTime export type DownloadStatusSubscriptionVariables = Exact<{ [key: string]: never; }>; -export type DownloadStatusSubscription = { __typename?: 'Subscription', downloadChanged: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, manga: { __typename?: 'MangaType', id: number, title: string } } }> } }; +export type DownloadStatusSubscription = { __typename?: 'Subscription', downloadChanged: { __typename?: 'DownloadStatus', state: DownloaderState, queue: Array<{ __typename?: 'DownloadType', progress: number, state: DownloadState, tries: number, chapter: { __typename?: 'ChapterType', id: number, name: string, sourceOrder: number, isDownloaded: boolean, manga: { __typename?: 'MangaType', id: number, title: string, downloadCount: number } } }> } }; export type WebuiUpdateSubscriptionVariables = Exact<{ [key: string]: never; }>; diff --git a/versionToServerVersionMapping.json b/versionToServerVersionMapping.json index 9ae1bc402d..f7e4316387 100644 --- a/versionToServerVersionMapping.json +++ b/versionToServerVersionMapping.json @@ -1,6 +1,6 @@ [ { "uiVersion": "PREVIEW", - "serverVersion": "r1436" + "serverVersion": "r1438" } ]