Feature/manga migration (#536)

* Add "migration" tab to "Browse" screen

* Add missing useEffect cleanup for navbar title and actions

* Make "SourceGridLayout" reusable

* Add migration tab to "Browse"

* Add migration logic
This commit is contained in:
schroda
2024-01-26 20:50:51 +01:00
committed by GitHub
parent 5224ad1391
commit e0c5e0521d
39 changed files with 1329 additions and 365 deletions

View File

@@ -172,6 +172,14 @@ import {
UpdateMangaCategoriesPatchInput,
GetWebuiUpdateStatusQuery,
GetWebuiUpdateStatusQueryVariables,
GetMigratableSourcesQuery,
GetMigratableSourcesQueryVariables,
GetMigratableSourceMangasQuery,
GetMigratableSourceMangasQueryVariables,
GetMangaToMigrateQuery,
GetMangaToMigrateQueryVariables,
GetMangaToMigrateToFetchMutation,
GetMangaToMigrateToFetchMutationVariables,
} from '@/lib/graphql/generated/graphql.ts';
import { GET_GLOBAL_METADATAS } from '@/lib/graphql/queries/GlobalMetadataQuery.ts';
import { SET_GLOBAL_METADATA } from '@/lib/graphql/mutations/GlobalMetadataMutation.ts';
@@ -187,16 +195,22 @@ import {
INSTALL_EXTERNAL_EXTENSION,
UPDATE_EXTENSION,
} from '@/lib/graphql/mutations/ExtensionMutation.ts';
import { GET_SOURCE, GET_SOURCES } from '@/lib/graphql/queries/SourceQuery.ts';
import { GET_MIGRATABLE_SOURCES, GET_SOURCE, GET_SOURCES } from '@/lib/graphql/queries/SourceQuery.ts';
import {
GET_MANGA_FETCH,
GET_MANGA_TO_MIGRATE_TO_FETCH,
SET_MANGA_METADATA,
UPDATE_MANGA,
UPDATE_MANGA_CATEGORIES,
UPDATE_MANGAS,
UPDATE_MANGAS_CATEGORIES,
} from '@/lib/graphql/mutations/MangaMutation.ts';
import { GET_MANGA, GET_MANGAS } from '@/lib/graphql/queries/MangaQuery.ts';
import {
GET_MANGA,
GET_MANGA_TO_MIGRATE,
GET_MANGAS,
GET_MIGRATABLE_SOURCE_MANGAS,
} from '@/lib/graphql/queries/MangaQuery.ts';
import { GET_CATEGORIES, GET_CATEGORY_MANGAS } from '@/lib/graphql/queries/CategoryQuery.ts';
import { GET_SOURCE_MANGAS_FETCH, UPDATE_SOURCE_PREFERENCES } from '@/lib/graphql/mutations/SourceMutation.ts';
import {
@@ -1330,6 +1344,33 @@ export class RequestManager {
return this.doRequest(GQLMethod.USE_QUERY, GET_MANGA, { id: Number(mangaId) }, options);
}
public getManga(
mangaId: number | string,
options?: QueryOptions<GetMangaQueryVariables, GetMangaQuery>,
): AbortabaleApolloQueryResponse<GetMangaQuery> {
return this.doRequest(GQLMethod.QUERY, GET_MANGA, { id: Number(mangaId) }, options);
}
public getMangaToMigrate(
mangaId: number | string,
{
migrateChapters = false,
migrateCategories = false,
apolloOptions: options,
}: {
migrateChapters?: boolean;
migrateCategories?: boolean;
apolloOptions?: QueryOptions<GetMangaToMigrateQueryVariables, GetMangaToMigrateQuery>;
} = {},
): AbortabaleApolloQueryResponse<GetMangaToMigrateQuery> {
return this.doRequest(
GQLMethod.QUERY,
GET_MANGA_TO_MIGRATE,
{ id: Number(mangaId), migrateChapters, migrateCategories },
options,
);
}
public getMangaFetch(
mangaId: number | string,
options?: MutationOptions<GetMangaFetchMutation, GetMangaFetchMutationVariables>,
@@ -1346,6 +1387,33 @@ export class RequestManager {
);
}
public getMangaToMigrateToFetch(
mangaId: number | string,
{
migrateChapters = false,
migrateCategories = false,
apolloOptions: options,
}: {
migrateChapters?: boolean;
migrateCategories?: boolean;
apolloOptions?: MutationOptions<
GetMangaToMigrateToFetchMutation,
GetMangaToMigrateToFetchMutationVariables
>;
} = {},
): AbortableApolloMutationResponse<GetMangaToMigrateToFetchMutation> {
return this.doRequest<GetMangaToMigrateToFetchMutation, GetMangaToMigrateToFetchMutationVariables>(
GQLMethod.MUTATION,
GET_MANGA_TO_MIGRATE_TO_FETCH,
{
id: Number(mangaId),
migrateChapters,
migrateCategories,
},
options,
);
}
public useGetMangas(
variables: GetMangasQueryVariables,
options?: QueryHookOptions<GetMangasQuery, GetMangasQueryVariables>,
@@ -1360,6 +1428,13 @@ export class RequestManager {
return this.doRequest(GQLMethod.QUERY, GET_MANGAS, variables, options);
}
public useGetMigratableSourceMangas(
sourceId: string,
options?: QueryHookOptions<GetMigratableSourceMangasQuery, GetMigratableSourceMangasQueryVariables>,
): AbortableApolloUseQueryResponse<GetMigratableSourceMangasQuery, GetMigratableSourceMangasQueryVariables> {
return this.doRequest(GQLMethod.USE_QUERY, GET_MIGRATABLE_SOURCE_MANGAS, { sourceId }, options);
}
public getMangaThumbnailUrl(mangaId: number): string {
return this.getValidImgUrlFor(`manga/${mangaId}/thumbnail`);
}
@@ -2182,6 +2257,12 @@ export class RequestManager {
): AbortableApolloUseQueryResponse<GetWebuiUpdateStatusQuery, GetWebuiUpdateStatusQueryVariables> {
return this.doRequest(GQLMethod.USE_QUERY, GET_WEBUI_UPDATE_STATUS, undefined, options);
}
public useGetMigratableSources(
options?: QueryHookOptions<GetMigratableSourcesQuery, GetMigratableSourcesQueryVariables>,
): AbortableApolloUseQueryResponse<GetMigratableSourcesQuery, GetMigratableSourcesQueryVariables> {
return this.doRequest(GQLMethod.USE_QUERY, GET_MIGRATABLE_SOURCES, undefined, options);
}
}
export const requestManager = new RequestManager();