Update "getMangasChapterIdsWithState"

This commit is contained in:
schroda
2026-05-20 16:26:43 +02:00
parent 3ae4d8d752
commit 19962df378
4 changed files with 52 additions and 40 deletions

View File

@@ -50,10 +50,12 @@ import { MigrationManager } from '@/features/migration/MigrationManager.ts';
import uniq from 'lodash/fp/uniq'; import uniq from 'lodash/fp/uniq';
import { ReactRouter } from '@/lib/react-router/ReactRouter.ts'; import { ReactRouter } from '@/lib/react-router/ReactRouter.ts';
import { AppRoutes } from '@/base/AppRoute.constants.ts'; import { AppRoutes } from '@/base/AppRoute.constants.ts';
import type { import {
ChapterConditionInput, ChapterOrderBy,
UpdateMangaCategoriesPatchInput, type ChapterConditionInput,
type UpdateMangaCategoriesPatchInput,
} from '@/lib/graphql/generated/graphql-base.types.ts'; } 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; const I18N_PLURAL = 9999;
@@ -183,7 +185,15 @@ export class Mangas {
mangaIds: number[], mangaIds: number[],
state: Pick<ChapterConditionInput, 'isRead' | 'isDownloaded' | 'isBookmarked'>, state: Pick<ChapterConditionInput, 'isRead' | 'isDownloaded' | 'isBookmarked'>,
): Promise<GetMangasChapterIdsWithStateQuery['chapters']['nodes']> { ): Promise<GetMangasChapterIdsWithStateQuery['chapters']['nodes']> {
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 ?? []; return data?.chapters.nodes ?? [];
} }

View File

@@ -165,17 +165,27 @@ export const GET_CHAPTERS_HISTORY = gql`
export const GET_MANGAS_CHAPTER_IDS_WITH_STATE = gql` export const GET_MANGAS_CHAPTER_IDS_WITH_STATE = gql`
${CHAPTER_STATE_FIELDS} ${CHAPTER_STATE_FIELDS}
${PAGE_INFO}
query GET_MANGAS_CHAPTER_IDS_WITH_STATE( query GET_MANGAS_CHAPTER_IDS_WITH_STATE(
$mangaIds: [Int!]! $after: Cursor
$isDownloaded: Boolean = null $before: Cursor
$isRead: Boolean = null $condition: ChapterConditionInput
$isBookmarked: Boolean = null $filter: ChapterFilterInput
$first: Int
$last: Int
$offset: Int
$order: [ChapterOrderInput!]
) { ) {
chapters( chapters(
filter: { mangaId: { in: $mangaIds } } after: $after
condition: { isDownloaded: $isDownloaded, isRead: $isRead, isBookmarked: $isBookmarked } before: $before
order: [{ by: SOURCE_ORDER }] condition: $condition
filter: $filter
first: $first
last: $last
offset: $offset
order: $order
) { ) {
nodes { nodes {
...CHAPTER_STATE_FIELDS ...CHAPTER_STATE_FIELDS
@@ -183,6 +193,10 @@ export const GET_MANGAS_CHAPTER_IDS_WITH_STATE = gql`
scanlator scanlator
chapterNumber chapterNumber
} }
pageInfo {
...PAGE_INFO
}
totalCount
} }
} }
`; `;

View File

@@ -931,16 +931,21 @@ export type GetChaptersHistoryQuery = {
}; };
export type GetMangasChapterIdsWithStateQueryVariables = Exact<{ export type GetMangasChapterIdsWithStateQueryVariables = Exact<{
mangaIds: Array<number> | number; after?: string | null | undefined;
isDownloaded?: boolean | null | undefined; before?: string | null | undefined;
isRead?: boolean | null | undefined; condition?: Types.ChapterConditionInput | null | undefined;
isBookmarked?: boolean | null | undefined; filter?: Types.ChapterFilterInput | null | undefined;
first?: number | null | undefined;
last?: number | null | undefined;
offset?: number | null | undefined;
order?: Array<Types.ChapterOrderInput> | Types.ChapterOrderInput | null | undefined;
}>; }>;
export type GetMangasChapterIdsWithStateQuery = { export type GetMangasChapterIdsWithStateQuery = {
__typename: 'Query'; __typename: 'Query';
chapters: { chapters: {
__typename: 'ChapterNodeList'; __typename: 'ChapterNodeList';
totalCount: number;
nodes: Array<{ nodes: Array<{
__typename: 'ChapterType'; __typename: 'ChapterType';
mangaId: number; mangaId: number;
@@ -951,6 +956,13 @@ export type GetMangasChapterIdsWithStateQuery = {
isDownloaded: boolean; isDownloaded: boolean;
isBookmarked: boolean; isBookmarked: boolean;
}>; }>;
pageInfo: {
__typename: 'PageInfo';
endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
};
}; };
}; };

View File

@@ -83,8 +83,6 @@ import type {
GetMangaChaptersFetchMutationVariables, GetMangaChaptersFetchMutationVariables,
GetMangaFetchMutation, GetMangaFetchMutation,
GetMangaFetchMutationVariables, GetMangaFetchMutationVariables,
GetMangasChapterIdsWithStateQuery,
GetMangasChapterIdsWithStateQueryVariables,
GetMangasLibraryQuery, GetMangasLibraryQuery,
GetMangasLibraryQueryVariables, GetMangasLibraryQueryVariables,
GetMangaToMigrateQuery, GetMangaToMigrateQuery,
@@ -190,7 +188,6 @@ import type {
WebuiUpdateSubscription, WebuiUpdateSubscription,
} from '@/lib/graphql/generated/graphql.ts'; } from '@/lib/graphql/generated/graphql.ts';
import type { import type {
ChapterConditionInput,
CreateBackupInput, CreateBackupInput,
CreateCategoryInput, CreateCategoryInput,
DeleteCategoryMetasInput, DeleteCategoryMetasInput,
@@ -272,12 +269,7 @@ import {
START_DOWNLOADER, START_DOWNLOADER,
STOP_DOWNLOADER, STOP_DOWNLOADER,
} from '@/lib/graphql/download/DownloaderMutation.ts'; } from '@/lib/graphql/download/DownloaderMutation.ts';
import { import { GET_CHAPTERS_HISTORY, GET_CHAPTERS_MANGA, GET_CHAPTERS_UPDATES } from '@/lib/graphql/chapter/ChapterQuery.ts';
GET_CHAPTERS_HISTORY,
GET_CHAPTERS_MANGA,
GET_CHAPTERS_UPDATES,
GET_MANGAS_CHAPTER_IDS_WITH_STATE,
} from '@/lib/graphql/chapter/ChapterQuery.ts';
import { import {
GET_CHAPTER_PAGES_FETCH, GET_CHAPTER_PAGES_FETCH,
GET_MANGA_CHAPTERS_FETCH, GET_MANGA_CHAPTERS_FETCH,
@@ -2536,22 +2528,6 @@ export class RequestManager {
); );
} }
public getMangasChapterIdsWithState(
mangaIds: number[],
states: Pick<ChapterConditionInput, 'isRead' | 'isDownloaded' | 'isBookmarked'>,
options?: QueryOptions<GetMangasChapterIdsWithStateQueryVariables, GetMangasChapterIdsWithStateQuery>,
): AbortabaleApolloQueryResponse<GetMangasChapterIdsWithStateQuery> {
return this.doRequest(
GQLMethod.QUERY,
GET_MANGAS_CHAPTER_IDS_WITH_STATE,
{ mangaIds, ...states } as GetMangasChapterIdsWithStateQueryVariables,
{
fetchPolicy: 'no-cache',
...options,
} as QueryOptions<GetMangasChapterIdsWithStateQueryVariables, GetMangasChapterIdsWithStateQuery>,
);
}
public getMangaChaptersFetch( public getMangaChaptersFetch(
mangaId: number | string, mangaId: number | string,
options?: MutationOptions<GetMangaChaptersFetchMutation, GetMangaChaptersFetchMutationVariables>, options?: MutationOptions<GetMangaChaptersFetchMutation, GetMangaChaptersFetchMutationVariables>,