Use gql for "updater"

This commit is contained in:
schroda
2023-09-01 20:40:39 +02:00
parent 222f8f5c9b
commit a5b4b95bce

View File

@@ -28,7 +28,6 @@ import {
IManga, IManga,
IMangaChapter, IMangaChapter,
ISourceFilters, ISourceFilters,
IUpdateStatus,
PaginatedList, PaginatedList,
PaginatedMangaList, PaginatedMangaList,
SourcePreferences, SourcePreferences,
@@ -74,6 +73,8 @@ import {
GetSourceQueryVariables, GetSourceQueryVariables,
GetSourcesQuery, GetSourcesQuery,
GetSourcesQueryVariables, GetSourcesQueryVariables,
GetUpdateStatusQuery,
GetUpdateStatusQueryVariables,
InstallExternalExtensionMutation, InstallExternalExtensionMutation,
InstallExternalExtensionMutationVariables, InstallExternalExtensionMutationVariables,
ReorderChapterDownloadMutation, ReorderChapterDownloadMutation,
@@ -89,6 +90,10 @@ import {
StartDownloaderMutationVariables, StartDownloaderMutationVariables,
StopDownloaderMutation, StopDownloaderMutation,
StopDownloaderMutationVariables, StopDownloaderMutationVariables,
StopUpdaterMutation,
StopUpdaterMutationVariables,
UpdateCategoryMangasMutation,
UpdateCategoryMangasMutationVariables,
UpdateCategoryMutation, UpdateCategoryMutation,
UpdateCategoryMutationVariables, UpdateCategoryMutationVariables,
UpdateCategoryOrderMutation, UpdateCategoryOrderMutation,
@@ -102,6 +107,8 @@ import {
UpdateExtensionMutation, UpdateExtensionMutation,
UpdateExtensionMutationVariables, UpdateExtensionMutationVariables,
UpdateExtensionPatchInput, UpdateExtensionPatchInput,
UpdateLibraryMangasMutation,
UpdateLibraryMangasMutationVariables,
UpdateMangaCategoriesMutation, UpdateMangaCategoriesMutation,
UpdateMangaCategoriesMutationVariables, UpdateMangaCategoriesMutationVariables,
UpdateMangaMutation, UpdateMangaMutation,
@@ -144,6 +151,12 @@ import {
UPDATE_CATEGORY_ORDER, UPDATE_CATEGORY_ORDER,
} from '@/lib/graphql/mutations/CategoryMutation.ts'; } from '@/lib/graphql/mutations/CategoryMutation.ts';
import { GET_DOWNLOAD_STATUS } from '@/lib/graphql/queries/DownloaderQuery.ts'; import { GET_DOWNLOAD_STATUS } from '@/lib/graphql/queries/DownloaderQuery.ts';
import {
STOP_UPDATER,
UPDATE_CATEGORY_MANGAS,
UPDATE_LIBRARY_MANGAS,
} from '@/lib/graphql/mutations/UpdaterMutation.ts';
import { GET_UPDATE_STATUS } from '@/lib/graphql/queries/UpdaterQuery.ts';
enum SWRHttpMethod { enum SWRHttpMethod {
SWR_GET, SWR_GET,
@@ -1040,16 +1053,40 @@ export class RequestManager {
}); });
} }
public startGlobalUpdate(categoryId?: number): AbortableAxiosResponse { public startGlobalUpdate(): AbortableApolloMutationResponse<UpdateLibraryMangasMutation>;
return this.doRequest(HttpMethod.POST, 'update/fetch', { formData: { categoryId } });
public startGlobalUpdate(categories: number[]): AbortableApolloMutationResponse<UpdateCategoryMangasMutation>;
public startGlobalUpdate(
categories?: number[],
): AbortableApolloMutationResponse<UpdateCategoryMangasMutation | UpdateLibraryMangasMutation> {
if (categories?.length) {
return this.doRequestNew<UpdateCategoryMangasMutation, UpdateCategoryMangasMutationVariables>(
GQLMethod.MUTATION,
UPDATE_CATEGORY_MANGAS,
{ input: { categories } },
);
}
return this.doRequestNew<UpdateLibraryMangasMutation, UpdateLibraryMangasMutationVariables>(
GQLMethod.MUTATION,
UPDATE_LIBRARY_MANGAS,
{},
);
} }
public resetGlobalUpdate(): AbortableAxiosResponse { public resetGlobalUpdate(): AbortableApolloMutationResponse<StopUpdaterMutation> {
return this.doRequest(HttpMethod.POST, 'update/reset'); return this.doRequestNew<StopUpdaterMutation, StopUpdaterMutationVariables>(
GQLMethod.MUTATION,
STOP_UPDATER,
{},
);
} }
public useGetGlobalUpdateSummary(swrOptions?: SWROptions<IUpdateStatus>): AbortableSWRResponse<IUpdateStatus> { public useGetGlobalUpdateSummary(
return this.doRequest(HttpMethod.SWR_GET, 'update/summary', { swrOptions }); options?: QueryHookOptions<GetUpdateStatusQuery, GetUpdateStatusQueryVariables>,
): AbortableApolloUseQueryResponse<GetUpdateStatusQuery, GetUpdateStatusQueryVariables> {
return this.doRequestNew(GQLMethod.USE_QUERY, GET_UPDATE_STATUS, {}, options);
} }
} }