Fix/add manga to library without dialog not adding default categories (#632)
* Add default categories when adding manga to library without dialog * Add manga to library and update categories in one mutation
This commit is contained in:
@@ -299,9 +299,11 @@ export class Mangas {
|
||||
? Mangas.migrateCategories(mangaToMigrateData.manga, mangaToMigrateToData.fetchManga.manga)
|
||||
: undefined,
|
||||
!mangaToMigrateToData.fetchManga.manga.inLibrary
|
||||
? requestManager.updateManga(mangaIdToMigrateTo, { inLibrary: true }).response
|
||||
? requestManager.updateManga(mangaIdToMigrateTo, { updateManga: { inLibrary: true } }).response
|
||||
: undefined,
|
||||
mode === 'migrate'
|
||||
? requestManager.updateManga(mangaId, { updateManga: { inLibrary: false } }).response
|
||||
: undefined,
|
||||
mode === 'migrate' ? requestManager.updateManga(mangaId, { inLibrary: false }).response : undefined,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2833,10 +2833,12 @@ export type SetMangaMetadataMutation = { __typename?: 'Mutation', setMangaMeta:
|
||||
|
||||
export type UpdateMangaMutationVariables = Exact<{
|
||||
input: UpdateMangaInput;
|
||||
updateCategoryInput: UpdateMangaCategoriesInput;
|
||||
updateCategories: Scalars['Boolean']['input'];
|
||||
}>;
|
||||
|
||||
|
||||
export type UpdateMangaMutation = { __typename?: 'Mutation', updateManga: { __typename?: 'UpdateMangaPayload', clientMutationId?: string | null, manga: { __typename?: 'MangaType', id: number, inLibrary: boolean, inLibraryAt: any, categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }> } } } };
|
||||
export type UpdateMangaMutation = { __typename?: 'Mutation', updateManga: { __typename?: 'UpdateMangaPayload', clientMutationId?: string | null, manga: { __typename?: 'MangaType', id: number, inLibrary: boolean, inLibraryAt: any } }, updateMangaCategories?: { __typename?: 'UpdateMangaCategoriesPayload', manga: { __typename?: 'MangaType', id: number, categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, mangas: { __typename?: 'MangaNodeList', totalCount: number } }> } } } };
|
||||
|
||||
export type UpdateMangasMutationVariables = Exact<{
|
||||
input: UpdateMangasInput;
|
||||
|
||||
@@ -99,13 +99,22 @@ export const SET_MANGA_METADATA = gql`
|
||||
`;
|
||||
|
||||
export const UPDATE_MANGA = gql`
|
||||
mutation UPDATE_MANGA($input: UpdateMangaInput!) {
|
||||
mutation UPDATE_MANGA(
|
||||
$input: UpdateMangaInput!
|
||||
$updateCategoryInput: UpdateMangaCategoriesInput!
|
||||
$updateCategories: Boolean!
|
||||
) {
|
||||
updateManga(input: $input) {
|
||||
clientMutationId
|
||||
manga {
|
||||
id
|
||||
inLibrary
|
||||
inLibraryAt
|
||||
}
|
||||
}
|
||||
updateMangaCategories(input: $updateCategoryInput) @include(if: $updateCategories) {
|
||||
manga {
|
||||
id
|
||||
categories {
|
||||
nodes {
|
||||
id
|
||||
|
||||
@@ -1560,13 +1560,17 @@ export class RequestManager {
|
||||
|
||||
public updateManga(
|
||||
id: number,
|
||||
patch: UpdateMangaPatchInput,
|
||||
patch: { updateManga: UpdateMangaPatchInput; updateMangaCategories?: UpdateMangaCategoriesPatchInput },
|
||||
options?: MutationOptions<UpdateMangaMutation, UpdateMangaMutationVariables>,
|
||||
): AbortableApolloMutationResponse<UpdateMangaMutation> {
|
||||
const result = this.doRequest<UpdateMangaMutation, UpdateMangaMutationVariables>(
|
||||
GQLMethod.MUTATION,
|
||||
UPDATE_MANGA,
|
||||
{ input: { id, patch } },
|
||||
{
|
||||
input: { id, patch: patch.updateManga },
|
||||
updateCategoryInput: { id, patch: patch.updateMangaCategories ?? {} },
|
||||
updateCategories: !!patch.updateMangaCategories,
|
||||
},
|
||||
options,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user