Use new "fetchMangaAndChapters" mutation

This commit is contained in:
schroda
2026-06-30 15:33:57 +02:00
parent ef0dbef9cd
commit aa6ededa10
9 changed files with 79 additions and 234 deletions

View File

@@ -7,9 +7,8 @@
*/
import gql from 'graphql-tag';
import { CHAPTER_LIST_FIELDS, CHAPTER_META_FIELDS } from '@/lib/graphql/chapter/ChapterFragments.ts';
import { CHAPTER_META_FIELDS } from '@/lib/graphql/chapter/ChapterFragments.ts';
import { TRACK_RECORD_BIND_FIELDS } from '@/lib/graphql/tracker/TrackRecordFragments.ts';
import { MANGA_CHAPTER_NODE_FIELDS, MANGA_CHAPTER_STAT_FIELDS } from '@/lib/graphql/manga/MangaFragments.ts';
// makes the server fetch and return the pages of a chapter
export const GET_CHAPTER_PAGES_FETCH = gql`
@@ -29,26 +28,6 @@ export const GET_CHAPTER_PAGES_FETCH = gql`
}
`;
// makes the server fetch and return the chapters of the manga
export const GET_MANGA_CHAPTERS_FETCH = gql`
${CHAPTER_LIST_FIELDS}
${MANGA_CHAPTER_STAT_FIELDS}
${MANGA_CHAPTER_NODE_FIELDS}
mutation GET_MANGA_CHAPTERS_FETCH($input: FetchChaptersInput!) {
fetchChapters(input: $input) {
chapters {
...CHAPTER_LIST_FIELDS
manga {
id
...MANGA_CHAPTER_STAT_FIELDS
...MANGA_CHAPTER_NODE_FIELDS
}
}
}
}
`;
export const UPDATE_CHAPTER = gql`
${TRACK_RECORD_BIND_FIELDS}

View File

@@ -570,6 +570,17 @@ export type FetchExtensionsPayloadFieldPolicy = {
clientMutationId?: FieldPolicy<any> | FieldReadFunction<any>;
extensions?: FieldPolicy<any> | FieldReadFunction<any>;
};
export type FetchMangaAndChaptersPayloadKeySpecifier = (
| 'chapters'
| 'clientMutationId'
| 'manga'
| FetchMangaAndChaptersPayloadKeySpecifier
)[];
export type FetchMangaAndChaptersPayloadFieldPolicy = {
chapters?: FieldPolicy<any> | FieldReadFunction<any>;
clientMutationId?: FieldPolicy<any> | FieldReadFunction<any>;
manga?: FieldPolicy<any> | FieldReadFunction<any>;
};
export type FetchMangaPayloadKeySpecifier = ('clientMutationId' | 'manga' | FetchMangaPayloadKeySpecifier)[];
export type FetchMangaPayloadFieldPolicy = {
clientMutationId?: FieldPolicy<any> | FieldReadFunction<any>;
@@ -905,6 +916,7 @@ export type MutationKeySpecifier = (
| 'fetchChapters'
| 'fetchExtensions'
| 'fetchManga'
| 'fetchMangaAndChapters'
| 'fetchSourceManga'
| 'fetchTrack'
| 'installExternalExtension'
@@ -985,6 +997,7 @@ export type MutationFieldPolicy = {
fetchChapters?: FieldPolicy<any> | FieldReadFunction<any>;
fetchExtensions?: FieldPolicy<any> | FieldReadFunction<any>;
fetchManga?: FieldPolicy<any> | FieldReadFunction<any>;
fetchMangaAndChapters?: FieldPolicy<any> | FieldReadFunction<any>;
fetchSourceManga?: FieldPolicy<any> | FieldReadFunction<any>;
fetchTrack?: FieldPolicy<any> | FieldReadFunction<any>;
installExternalExtension?: FieldPolicy<any> | FieldReadFunction<any>;
@@ -2712,6 +2725,13 @@ export type StrictTypedTypePolicies = {
keyFields?: false | FetchExtensionsPayloadKeySpecifier | (() => undefined | FetchExtensionsPayloadKeySpecifier);
fields?: FetchExtensionsPayloadFieldPolicy;
};
FetchMangaAndChaptersPayload?: Omit<TypePolicy, 'fields' | 'keyFields'> & {
keyFields?:
| false
| FetchMangaAndChaptersPayloadKeySpecifier
| (() => undefined | FetchMangaAndChaptersPayloadKeySpecifier);
fields?: FetchMangaAndChaptersPayloadFieldPolicy;
};
FetchMangaPayload?: Omit<TypePolicy, 'fields' | 'keyFields'> & {
keyFields?: false | FetchMangaPayloadKeySpecifier | (() => undefined | FetchMangaPayloadKeySpecifier);
fields?: FetchMangaPayloadFieldPolicy;

View File

@@ -828,6 +828,20 @@ export type FetchExtensionsPayload = {
extensions: Array<ExtensionType>;
};
export type FetchMangaAndChaptersInput = {
clientMutationId?: InputMaybe<Scalars['String']['input']>;
fetchChapters: Scalars['Boolean']['input'];
fetchManga: Scalars['Boolean']['input'];
id: Scalars['Int']['input'];
};
export type FetchMangaAndChaptersPayload = {
__typename?: 'FetchMangaAndChaptersPayload';
chapters: Array<ChapterType>;
clientMutationId?: Maybe<Scalars['String']['output']>;
manga: MangaType;
};
export type FetchMangaInput = {
clientMutationId?: InputMaybe<Scalars['String']['input']>;
id: Scalars['Int']['input'];
@@ -1346,9 +1360,12 @@ export type Mutation = {
enqueueChapterDownload?: Maybe<EnqueueChapterDownloadPayload>;
enqueueChapterDownloads?: Maybe<EnqueueChapterDownloadsPayload>;
fetchChapterPages?: Maybe<FetchChapterPagesPayload>;
/** @deprecated Deprecated in Tachiyomix 1.6, replace with fetchMangaAndChapters */
fetchChapters?: Maybe<FetchChaptersPayload>;
fetchExtensions?: Maybe<FetchExtensionsPayload>;
/** @deprecated Deprecated in Tachiyomix 1.6, replace with fetchMangaAndChapters */
fetchManga?: Maybe<FetchMangaPayload>;
fetchMangaAndChapters?: Maybe<FetchMangaAndChaptersPayload>;
fetchSourceManga?: Maybe<FetchSourceMangaPayload>;
fetchTrack: FetchTrackPayload;
installExternalExtension?: Maybe<InstallExternalExtensionPayload>;
@@ -1512,6 +1529,10 @@ export type MutationFetchMangaArgs = {
input: FetchMangaInput;
};
export type MutationFetchMangaAndChaptersArgs = {
input: FetchMangaAndChaptersInput;
};
export type MutationFetchSourceMangaArgs = {
input: FetchSourceMangaInput;
};

View File

@@ -529,67 +529,6 @@ export type GetChapterPagesFetchMutation = {
} | null;
};
export type GetMangaChaptersFetchMutationVariables = Exact<{
input: Types.FetchChaptersInput;
}>;
export type GetMangaChaptersFetchMutation = {
__typename: 'Mutation';
fetchChapters: {
__typename: 'FetchChaptersPayload';
chapters: Array<{
__typename: 'ChapterType';
fetchedAt: string;
uploadDate: string;
lastReadAt: string;
id: number;
name: string;
mangaId: number;
scanlator: string | null;
realUrl: string | null;
sourceOrder: number;
chapterNumber: number;
isRead: boolean;
isDownloaded: boolean;
isBookmarked: boolean;
manga: {
__typename: 'MangaType';
id: number;
unreadCount: number;
downloadCount: number;
bookmarkCount: number;
hasDuplicateChapters: boolean;
chapters: { __typename: 'ChapterNodeList'; totalCount: number };
firstUnreadChapter: {
__typename: 'ChapterType';
id: number;
sourceOrder: number;
isRead: boolean;
mangaId: number;
chapterNumber: number;
name: string;
scanlator: string | null;
} | null;
lastReadChapter: {
__typename: 'ChapterType';
id: number;
sourceOrder: number;
lastReadAt: string;
} | null;
latestReadChapter: {
__typename: 'ChapterType';
id: number;
sourceOrder: number;
lastReadAt: string;
} | null;
latestFetchedChapter: { __typename: 'ChapterType'; id: number; fetchedAt: string } | null;
latestUploadedChapter: { __typename: 'ChapterType'; id: number; uploadDate: string } | null;
highestNumberedChapter: { __typename: 'ChapterType'; id: number; chapterNumber: number } | null;
};
}>;
} | null;
};
export type UpdateChapterMutationVariables = Exact<{
input: Types.UpdateChapterInput;
getBookmarked: boolean;
@@ -1778,15 +1717,17 @@ export type MangaLibraryDuplicateScreenFieldsFragment = {
chapters: { __typename: 'ChapterNodeList'; totalCount: number };
};
export type GetMangaFetchMutationVariables = Exact<{
input: Types.FetchMangaInput;
export type RefreshMangaMutationVariables = Exact<{
id: number;
fetchManga: boolean;
fetchChapters: boolean;
}>;
export type GetMangaFetchMutation = {
export type RefreshMangaMutation = {
__typename: 'Mutation';
fetchManga: {
__typename: 'FetchMangaPayload';
manga: {
fetchMangaAndChapters: {
__typename: 'FetchMangaAndChaptersPayload';
manga?: {
__typename: 'MangaType';
artist: string | null;
author: string | null;
@@ -1843,18 +1784,7 @@ export type GetMangaFetchMutation = {
highestNumberedChapter: { __typename: 'ChapterType'; id: number; chapterNumber: number } | null;
chapters: { __typename: 'ChapterNodeList'; totalCount: number };
};
} | null;
};
export type RefreshMangaMutationVariables = Exact<{
id: number;
}>;
export type RefreshMangaMutation = {
__typename: 'Mutation';
fetchChapters: {
__typename: 'FetchChaptersPayload';
chapters: Array<{
chapters?: Array<{
__typename: 'ChapterType';
fetchedAt: string;
uploadDate: string;
@@ -1871,66 +1801,6 @@ export type RefreshMangaMutation = {
isBookmarked: boolean;
}>;
} | null;
fetchManga: {
__typename: 'FetchMangaPayload';
manga: {
__typename: 'MangaType';
artist: string | null;
author: string | null;
description: string | null;
status: Types.MangaStatus;
realUrl: string | null;
sourceId: string;
genre: Array<string>;
lastFetchedAt: string | null;
inLibraryAt: string;
id: number;
title: string;
thumbnailUrl: string | null;
thumbnailUrlLastFetched: string | null;
inLibrary: boolean;
initialized: boolean;
unreadCount: number;
downloadCount: number;
bookmarkCount: number;
hasDuplicateChapters: boolean;
meta: Array<{ __typename: 'MangaMetaType'; mangaId: number; key: string; value: string }>;
source: {
__typename: 'SourceType';
id: string;
name: string;
displayName: string;
lang: string;
iconUrl: string;
} | null;
trackRecords: {
__typename: 'TrackRecordNodeList';
totalCount: number;
nodes: Array<{ __typename: 'TrackRecordType'; id: number; trackerId: number }>;
};
firstUnreadChapter: {
__typename: 'ChapterType';
id: number;
sourceOrder: number;
isRead: boolean;
mangaId: number;
chapterNumber: number;
name: string;
scanlator: string | null;
} | null;
lastReadChapter: { __typename: 'ChapterType'; id: number; sourceOrder: number; lastReadAt: string } | null;
latestReadChapter: {
__typename: 'ChapterType';
id: number;
sourceOrder: number;
lastReadAt: string;
} | null;
latestFetchedChapter: { __typename: 'ChapterType'; id: number; fetchedAt: string } | null;
latestUploadedChapter: { __typename: 'ChapterType'; id: number; uploadDate: string } | null;
highestNumberedChapter: { __typename: 'ChapterType'; id: number; chapterNumber: number } | null;
chapters: { __typename: 'ChapterNodeList'; totalCount: number };
};
} | null;
};
export type GetMangaToMigrateToFetchMutationVariables = Exact<{
@@ -1942,8 +1812,8 @@ export type GetMangaToMigrateToFetchMutationVariables = Exact<{
export type GetMangaToMigrateToFetchMutation = {
__typename: 'Mutation';
fetchManga: {
__typename: 'FetchMangaPayload';
fetchMangaAndChapters: {
__typename: 'FetchMangaAndChaptersPayload';
manga: {
__typename: 'MangaType';
id: number;
@@ -1955,10 +1825,7 @@ export type GetMangaToMigrateToFetchMutation = {
nodes: Array<{ __typename: 'TrackRecordType'; id: number; remoteId: string; trackerId: number }>;
};
};
} | null;
fetchChapters?: {
__typename: 'FetchChaptersPayload';
chapters: Array<{
chapters?: Array<{
__typename: 'ChapterType';
id: number;
chapterNumber: number;

View File

@@ -10,34 +10,19 @@ import gql from 'graphql-tag';
import { MANGA_META_FIELDS, MANGA_SCREEN_FIELDS } from '@/lib/graphql/manga/MangaFragments.ts';
import { CHAPTER_LIST_FIELDS } from '@/lib/graphql/chapter/ChapterFragments.ts';
// makes the server fetch and return the manga
export const GET_MANGA_FETCH = gql`
${MANGA_SCREEN_FIELDS}
mutation GET_MANGA_FETCH($input: FetchMangaInput!) {
fetchManga(input: $input) {
manga {
...MANGA_SCREEN_FIELDS
}
}
}
`;
// makes the server fetch and return the manga
export const REFRESH_MANGA = gql`
${MANGA_SCREEN_FIELDS}
${CHAPTER_LIST_FIELDS}
mutation REFRESH_MANGA($id: Int!) {
fetchChapters(input: { mangaId: $id }) {
chapters {
...CHAPTER_LIST_FIELDS
}
}
fetchManga(input: { id: $id }) {
manga {
mutation REFRESH_MANGA($id: Int!, $fetchManga: Boolean!, $fetchChapters: Boolean!) {
fetchMangaAndChapters(input: { id: $id, fetchManga: $fetchManga, fetchChapters: $fetchChapters }) {
manga @include(if: $fetchManga) {
...MANGA_SCREEN_FIELDS
}
chapters @include(if: $fetchChapters) {
...CHAPTER_LIST_FIELDS
}
}
}
`;
@@ -50,7 +35,7 @@ export const GET_MANGA_TO_MIGRATE_TO_FETCH = gql`
$migrateCategories: Boolean!
$migrateTracking: Boolean!
) {
fetchManga(input: { id: $id }) {
fetchMangaAndChapters(input: { id: $id, fetchManga: true, fetchChapters: $migrateChapters }) {
manga {
id
title
@@ -68,9 +53,7 @@ export const GET_MANGA_TO_MIGRATE_TO_FETCH = gql`
}
}
}
}
fetchChapters(input: { mangaId: $id }) @include(if: $migrateChapters) {
chapters {
chapters @include(if: $migrateChapters) {
id
manga {
id

View File

@@ -80,10 +80,6 @@ import type {
GetKoSyncStatusQueryVariables,
GetLastUpdateTimestampQuery,
GetLastUpdateTimestampQueryVariables,
GetMangaChaptersFetchMutation,
GetMangaChaptersFetchMutationVariables,
GetMangaFetchMutation,
GetMangaFetchMutationVariables,
GetMangasLibraryQuery,
GetMangasLibraryQueryVariables,
GetMangaToMigrateQuery,
@@ -240,7 +236,6 @@ import {
} from '@/lib/graphql/extension/ExtensionMutation.ts';
import { GET_MIGRATABLE_SOURCES, GET_SOURCES_LIST } from '@/lib/graphql/source/SourceQuery.ts';
import {
GET_MANGA_FETCH,
GET_MANGA_TO_MIGRATE_TO_FETCH,
REFRESH_MANGA,
UPDATE_MANGA,
@@ -281,7 +276,6 @@ import {
} from '@/lib/graphql/chapter/ChapterQuery.ts';
import {
GET_CHAPTER_PAGES_FETCH,
GET_MANGA_CHAPTERS_FETCH,
UPDATE_CHAPTER,
UPDATE_CHAPTER_METADATA,
UPDATE_CHAPTERS,
@@ -2205,33 +2199,26 @@ export class RequestManager {
);
}
public getMangaFetch(
mangaId: number | string,
options?: MutationOptions<GetMangaFetchMutation, GetMangaFetchMutationVariables>,
): AbortableApolloMutationResponse<GetMangaFetchMutation> {
return this.doRequest<GetMangaFetchMutation, GetMangaFetchMutationVariables>(
GQLMethod.MUTATION,
GET_MANGA_FETCH,
{
input: {
id: Number(mangaId),
},
},
options,
);
}
public refreshManga(
mangaId: number | string,
options?: MutationOptions<RefreshMangaMutation, RefreshMangaMutationVariables>,
{
fetchManga = true,
fetchChapters = true,
...options
}: MutationOptions<RefreshMangaMutation, RefreshMangaMutationVariables> & {
fetchManga?: boolean;
fetchChapters?: boolean;
} = {},
): AbortableApolloMutationResponse<RefreshMangaMutation> {
return this.doRequest<RefreshMangaMutation, RefreshMangaMutationVariables>(
GQLMethod.MUTATION,
REFRESH_MANGA,
{
id: Number(mangaId),
fetchManga,
fetchChapters,
},
{ refetchQueries: [GET_CHAPTERS_MANGA, GET_CHAPTERS_READER], errorPolicy: 'all', ...options },
{ refetchQueries: [GET_CHAPTERS_MANGA, GET_CHAPTERS_READER], ...options },
);
}
@@ -2556,18 +2543,6 @@ export class RequestManager {
);
}
public getMangaChaptersFetch(
mangaId: number | string,
options?: MutationOptions<GetMangaChaptersFetchMutation, GetMangaChaptersFetchMutationVariables>,
): AbortableApolloMutationResponse<GetMangaChaptersFetchMutation> {
return this.doRequest<GetMangaChaptersFetchMutation, GetMangaChaptersFetchMutationVariables>(
GQLMethod.MUTATION,
GET_MANGA_CHAPTERS_FETCH,
{ input: { mangaId: Number(mangaId) } },
{ refetchQueries: [GET_CHAPTERS_MANGA], ...options },
);
}
public useGetMangaChapter(
mangaId: number | string,
chapterIndex: number | string,