Skip to content

Commit

Permalink
Use gql for "mangas" V - update manga categories
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda committed Oct 27, 2023
1 parent 87aef85 commit 3297c7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/navbar/action/CategorySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -66,7 +66,7 @@ export default function CategorySelect(props: IProps) {
},
},
},
}).then(() => mutate());
});
};

return (
Expand Down
8 changes: 0 additions & 8 deletions src/lib/requests/RequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { OperationVariables } from '@apollo/client/core';
import { useEffect, useRef, useState } from 'react';
import {
BackupValidationResult,
ICategory,
IChapter,
IMangaChapter,
ISourceFilters,
Expand Down Expand Up @@ -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> {
Expand Down

0 comments on commit 3297c7d

Please sign in to comment.