From 19962df3785d67c928972f22125da73d8674b3dd Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 20 May 2026 16:26:43 +0200 Subject: [PATCH] Update "getMangasChapterIdsWithState" --- src/features/manga/services/Mangas.ts | 18 ++++++++++++---- src/lib/graphql/chapter/ChapterQuery.ts | 28 ++++++++++++++++++------- src/lib/graphql/generated/graphql.ts | 20 ++++++++++++++---- src/lib/requests/RequestManager.ts | 26 +---------------------- 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/features/manga/services/Mangas.ts b/src/features/manga/services/Mangas.ts index a10b179c..3f4c2064 100644 --- a/src/features/manga/services/Mangas.ts +++ b/src/features/manga/services/Mangas.ts @@ -50,10 +50,12 @@ import { MigrationManager } from '@/features/migration/MigrationManager.ts'; import uniq from 'lodash/fp/uniq'; import { ReactRouter } from '@/lib/react-router/ReactRouter.ts'; import { AppRoutes } from '@/base/AppRoute.constants.ts'; -import type { - ChapterConditionInput, - UpdateMangaCategoriesPatchInput, +import { + ChapterOrderBy, + type ChapterConditionInput, + type UpdateMangaCategoriesPatchInput, } from '@/lib/graphql/generated/graphql-base.types.ts'; +import { GET_MANGAS_CHAPTER_IDS_WITH_STATE } from '@/lib/graphql/chapter/ChapterQuery.ts'; const I18N_PLURAL = 9999; @@ -183,7 +185,15 @@ export class Mangas { mangaIds: number[], state: Pick, ): Promise { - const { data } = await requestManager.getMangasChapterIdsWithState(mangaIds, state).response; + const { data } = await requestManager.getChapters< + GetMangasChapterIdsWithStateQuery, + GetMangasChapterIdsWithStateQueryVariables + >(GET_MANGAS_CHAPTER_IDS_WITH_STATE, { + filter: { mangaId: { in: mangaIds } }, + condition: { ...state }, + order: [{ by: ChapterOrderBy.SourceOrder }], + }).response; + return data?.chapters.nodes ?? []; } diff --git a/src/lib/graphql/chapter/ChapterQuery.ts b/src/lib/graphql/chapter/ChapterQuery.ts index 9e51d072..794db91f 100644 --- a/src/lib/graphql/chapter/ChapterQuery.ts +++ b/src/lib/graphql/chapter/ChapterQuery.ts @@ -165,17 +165,27 @@ export const GET_CHAPTERS_HISTORY = gql` export const GET_MANGAS_CHAPTER_IDS_WITH_STATE = gql` ${CHAPTER_STATE_FIELDS} + ${PAGE_INFO} query GET_MANGAS_CHAPTER_IDS_WITH_STATE( - $mangaIds: [Int!]! - $isDownloaded: Boolean = null - $isRead: Boolean = null - $isBookmarked: Boolean = null + $after: Cursor + $before: Cursor + $condition: ChapterConditionInput + $filter: ChapterFilterInput + $first: Int + $last: Int + $offset: Int + $order: [ChapterOrderInput!] ) { chapters( - filter: { mangaId: { in: $mangaIds } } - condition: { isDownloaded: $isDownloaded, isRead: $isRead, isBookmarked: $isBookmarked } - order: [{ by: SOURCE_ORDER }] + after: $after + before: $before + condition: $condition + filter: $filter + first: $first + last: $last + offset: $offset + order: $order ) { nodes { ...CHAPTER_STATE_FIELDS @@ -183,6 +193,10 @@ export const GET_MANGAS_CHAPTER_IDS_WITH_STATE = gql` scanlator chapterNumber } + pageInfo { + ...PAGE_INFO + } + totalCount } } `; diff --git a/src/lib/graphql/generated/graphql.ts b/src/lib/graphql/generated/graphql.ts index aa448152..3812e187 100644 --- a/src/lib/graphql/generated/graphql.ts +++ b/src/lib/graphql/generated/graphql.ts @@ -931,16 +931,21 @@ export type GetChaptersHistoryQuery = { }; export type GetMangasChapterIdsWithStateQueryVariables = Exact<{ - mangaIds: Array | number; - isDownloaded?: boolean | null | undefined; - isRead?: boolean | null | undefined; - isBookmarked?: boolean | null | undefined; + after?: string | null | undefined; + before?: string | null | undefined; + condition?: Types.ChapterConditionInput | null | undefined; + filter?: Types.ChapterFilterInput | null | undefined; + first?: number | null | undefined; + last?: number | null | undefined; + offset?: number | null | undefined; + order?: Array | Types.ChapterOrderInput | null | undefined; }>; export type GetMangasChapterIdsWithStateQuery = { __typename: 'Query'; chapters: { __typename: 'ChapterNodeList'; + totalCount: number; nodes: Array<{ __typename: 'ChapterType'; mangaId: number; @@ -951,6 +956,13 @@ export type GetMangasChapterIdsWithStateQuery = { isDownloaded: boolean; isBookmarked: boolean; }>; + pageInfo: { + __typename: 'PageInfo'; + endCursor: string | null; + hasNextPage: boolean; + hasPreviousPage: boolean; + startCursor: string | null; + }; }; }; diff --git a/src/lib/requests/RequestManager.ts b/src/lib/requests/RequestManager.ts index 4c385545..a7b91f02 100644 --- a/src/lib/requests/RequestManager.ts +++ b/src/lib/requests/RequestManager.ts @@ -83,8 +83,6 @@ import type { GetMangaChaptersFetchMutationVariables, GetMangaFetchMutation, GetMangaFetchMutationVariables, - GetMangasChapterIdsWithStateQuery, - GetMangasChapterIdsWithStateQueryVariables, GetMangasLibraryQuery, GetMangasLibraryQueryVariables, GetMangaToMigrateQuery, @@ -190,7 +188,6 @@ import type { WebuiUpdateSubscription, } from '@/lib/graphql/generated/graphql.ts'; import type { - ChapterConditionInput, CreateBackupInput, CreateCategoryInput, DeleteCategoryMetasInput, @@ -272,12 +269,7 @@ import { START_DOWNLOADER, STOP_DOWNLOADER, } from '@/lib/graphql/download/DownloaderMutation.ts'; -import { - GET_CHAPTERS_HISTORY, - GET_CHAPTERS_MANGA, - GET_CHAPTERS_UPDATES, - GET_MANGAS_CHAPTER_IDS_WITH_STATE, -} from '@/lib/graphql/chapter/ChapterQuery.ts'; +import { GET_CHAPTERS_HISTORY, GET_CHAPTERS_MANGA, GET_CHAPTERS_UPDATES } from '@/lib/graphql/chapter/ChapterQuery.ts'; import { GET_CHAPTER_PAGES_FETCH, GET_MANGA_CHAPTERS_FETCH, @@ -2536,22 +2528,6 @@ export class RequestManager { ); } - public getMangasChapterIdsWithState( - mangaIds: number[], - states: Pick, - options?: QueryOptions, - ): AbortabaleApolloQueryResponse { - return this.doRequest( - GQLMethod.QUERY, - GET_MANGAS_CHAPTER_IDS_WITH_STATE, - { mangaIds, ...states } as GetMangasChapterIdsWithStateQueryVariables, - { - fetchPolicy: 'no-cache', - ...options, - } as QueryOptions, - ); - } - public getMangaChaptersFetch( mangaId: number | string, options?: MutationOptions,