Use gql for "mangas" V - update manga categories
This commit is contained in:
@@ -29,7 +29,7 @@ export default function CategorySelect(props: IProps) {
|
||||
|
||||
const { open, setOpen, mangaId } = props;
|
||||
|
||||
const { data: mangaCategoriesData, mutate } = requestManager.useGetMangaCategories(mangaId);
|
||||
const { data: mangaResult } = requestManager.useGetManga(mangaId);
|
||||
const { data } = requestManager.useGetCategories();
|
||||
const categoriesData = data?.categories.nodes;
|
||||
const [triggerMutate] = requestManager.useUpdateMangaCategories();
|
||||
@@ -42,7 +42,7 @@ export default function CategorySelect(props: IProps) {
|
||||
return cats;
|
||||
}, [categoriesData]);
|
||||
|
||||
const selectedIds = mangaCategoriesData?.map((c) => c.id) ?? [];
|
||||
const selectedIds = mangaResult?.manga.categories.nodes.map((c) => c.id) ?? [];
|
||||
|
||||
const handleCancel = () => {
|
||||
setOpen(false);
|
||||
@@ -66,7 +66,7 @@ export default function CategorySelect(props: IProps) {
|
||||
},
|
||||
},
|
||||
},
|
||||
}).then(() => mutate());
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -26,7 +26,6 @@ import { OperationVariables } from '@apollo/client/core';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
BackupValidationResult,
|
||||
ICategory,
|
||||
IChapter,
|
||||
IMangaChapter,
|
||||
ISourceFilters,
|
||||
@@ -1292,13 +1291,6 @@ export class RequestManager {
|
||||
return this.getValidImgUrlFor(`manga/${mangaId}/thumbnail`);
|
||||
}
|
||||
|
||||
public useGetMangaCategories(
|
||||
mangaId: number,
|
||||
swrOptions?: SWROptions<ICategory[]>,
|
||||
): AbortableSWRResponse<ICategory[]> {
|
||||
return this.doRequest(HttpMethod.SWR_GET, `manga/${mangaId}/category`, { swrOptions });
|
||||
}
|
||||
|
||||
public useUpdateMangaCategories(
|
||||
options?: MutationHookOptions<UpdateMangaCategoriesMutation, UpdateMangaCategoriesMutationVariables>,
|
||||
): AbortableApolloUseMutationResponse<UpdateMangaCategoriesMutation, UpdateMangaCategoriesMutationVariables> {
|
||||
|
||||
Reference in New Issue
Block a user