diff --git a/src/api/generated/api.schemas.ts b/src/api/generated/api.schemas.ts index da97080..68b7f4e 100644 --- a/src/api/generated/api.schemas.ts +++ b/src/api/generated/api.schemas.ts @@ -192,17 +192,17 @@ export interface PageMangaImportJobDTO { number?: number; pageable?: PageableObject; numberOfElements?: number; + sort?: SortObject; first?: boolean; last?: boolean; - sort?: SortObject; empty?: boolean; } export interface PageableObject { offset?: number; + paged?: boolean; pageNumber?: number; pageSize?: number; - paged?: boolean; unpaged?: boolean; sort?: SortObject; } @@ -254,9 +254,9 @@ export interface PageMangaListDTO { number?: number; pageable?: PageableObject; numberOfElements?: number; + sort?: SortObject; first?: boolean; last?: boolean; - sort?: SortObject; empty?: boolean; } diff --git a/src/api/generated/ingestion/ingestion.ts b/src/api/generated/ingestion/ingestion.ts index 0ce1ae3..bb7711e 100644 --- a/src/api/generated/ingestion/ingestion.ts +++ b/src/api/generated/ingestion/ingestion.ts @@ -289,6 +289,69 @@ export const useFetchContentProviderContentList = ,signal?: AbortSignal +) => { + + + return customInstance( + {url: `/ingestion/manga-content-providers/${encodeURIComponent(String(mangaContentProviderId))}/fetch-all-chapters`, method: 'POST', signal + }, + options); + } + + + +export const getFetchAllContentImagesMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{mangaContentProviderId: number}, TContext>, request?: SecondParameter} +): UseMutationOptions>, TError,{mangaContentProviderId: number}, TContext> => { + +const mutationKey = ['fetchAllContentImages']; +const {mutation: mutationOptions, request: requestOptions} = options ? + options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? + options + : {...options, mutation: {...options.mutation, mutationKey}} + : {mutation: { mutationKey, }, request: undefined}; + + + + + const mutationFn: MutationFunction>, {mangaContentProviderId: number}> = (props) => { + const {mangaContentProviderId} = props ?? {}; + + return fetchAllContentImages(mangaContentProviderId,requestOptions) + } + + + + + return { mutationFn, ...mutationOptions }} + + export type FetchAllContentImagesMutationResult = NonNullable>> + + export type FetchAllContentImagesMutationError = unknown + + /** + * @summary Fetch all content's images + */ +export const useFetchAllContentImages = (options?: { mutation?:UseMutationOptions>, TError,{mangaContentProviderId: number}, TContext>, request?: SecondParameter} + , queryClient?: QueryClient): UseMutationResult< + Awaited>, + TError, + {mangaContentProviderId: number}, + TContext + > => { + + const mutationOptions = getFetchAllContentImagesMutationOptions(options); + + return useMutation(mutationOptions, queryClient); + } + /** * Retrieve a list of content providers * @summary Get a list of content providers */ diff --git a/src/api/generated/manga-chapter/manga-chapter.ts b/src/api/generated/manga-chapter/manga-chapter.ts deleted file mode 100644 index 17caf5d..0000000 --- a/src/api/generated/manga-chapter/manga-chapter.ts +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Generated by orval v7.17.0 🍺 - * Do not edit manually. - * OpenAPI definition - * OpenAPI spec version: v0 - */ -import { - useMutation -} from '@tanstack/react-query'; -import type { - MutationFunction, - QueryClient, - UseMutationOptions, - UseMutationResult -} from '@tanstack/react-query'; - -import type { - DefaultResponseDTOVoid -} from '../api.schemas'; - -import { customInstance } from '../../api'; - - -type SecondParameter unknown> = Parameters[1]; - - - -/** - * Fetch all not yet downloaded chapters from the provider - * @summary Fetch all chapters - */ -export const fetchAllChapters = ( - mangaProviderId: number, - options?: SecondParameter,signal?: AbortSignal -) => { - - - return customInstance( - {url: `/mangas/${encodeURIComponent(String(mangaProviderId))}/fetch-all-chapters`, method: 'POST', signal - }, - options); - } - - - -export const getFetchAllChaptersMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{mangaProviderId: number}, TContext>, request?: SecondParameter} -): UseMutationOptions>, TError,{mangaProviderId: number}, TContext> => { - -const mutationKey = ['fetchAllChapters']; -const {mutation: mutationOptions, request: requestOptions} = options ? - options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ? - options - : {...options, mutation: {...options.mutation, mutationKey}} - : {mutation: { mutationKey, }, request: undefined}; - - - - - const mutationFn: MutationFunction>, {mangaProviderId: number}> = (props) => { - const {mangaProviderId} = props ?? {}; - - return fetchAllChapters(mangaProviderId,requestOptions) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type FetchAllChaptersMutationResult = NonNullable>> - - export type FetchAllChaptersMutationError = unknown - - /** - * @summary Fetch all chapters - */ -export const useFetchAllChapters = (options?: { mutation?:UseMutationOptions>, TError,{mangaProviderId: number}, TContext>, request?: SecondParameter} - , queryClient?: QueryClient): UseMutationResult< - Awaited>, - TError, - {mangaProviderId: number}, - TContext - > => { - - const mutationOptions = getFetchAllChaptersMutationOptions(options); - - return useMutation(mutationOptions, queryClient); - } - \ No newline at end of file diff --git a/src/pages/Manga.tsx b/src/pages/Manga.tsx index d94a315..ee1028a 100644 --- a/src/pages/Manga.tsx +++ b/src/pages/Manga.tsx @@ -14,7 +14,7 @@ import { useCallback } from "react"; import { useNavigate, useParams } from "react-router"; import { toast } from "sonner"; import { useGetManga } from "@/api/generated/catalog/catalog.ts"; -import { useFetchContentProviderContentList } from "@/api/generated/ingestion/ingestion.ts"; +import {useFetchAllContentImages, useFetchContentProviderContentList} from "@/api/generated/ingestion/ingestion.ts"; import { useFollowManga, useSetFavorite, @@ -53,12 +53,12 @@ const Manga = () => { }, }); - // const { mutate: fetchAllMutate, isPending: fetchAllPending } = - // useFetchAllChapters({ - // mutation: { - // onSuccess: () => toast.success("Chapter import queued successfully."), - // }, - // }); + const { mutate: fetchAllMutate, isPending: fetchAllPending } = + useFetchAllContentImages({ + mutation: { + onSuccess: () => toast.success("Chapter import queued successfully."), + }, + }); const isPending = fetchPending; @@ -368,24 +368,24 @@ const Manga = () => { {provider.supportsChapterFetch && provider.active && (
- {/**/} - {/* fetchAllMutate({*/} - {/* mangaProviderId: provider.id?? -1,*/} - {/* })*/} - {/* }*/} - {/* className="gap-2"*/} - {/*>*/} - {/* */} - {/* Fetch all from Provider*/} - {/**/} +
)}