From 7a5b5624e787b7090b1ed3c6009583b40fb97c26 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Fri, 15 May 2026 12:28:08 +0200 Subject: [PATCH] Move migration types to corresponding file --- src/features/migration/MangaMigration.ts | 40 ++++++----------------- src/features/migration/Migration.types.ts | 30 +++++++++++++++-- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/features/migration/MangaMigration.ts b/src/features/migration/MangaMigration.ts index 2b2bfdf9..e306df7e 100644 --- a/src/features/migration/MangaMigration.ts +++ b/src/features/migration/MangaMigration.ts @@ -7,44 +7,24 @@ */ import { requestManager } from '@/lib/requests/RequestManager.ts'; -import type { - GetMangaToMigrateQuery, - GetMangaToMigrateToFetchMutation, - SetChapterMetasItemInput, -} from '@/lib/graphql/generated/graphql.ts'; +import type { SetChapterMetasItemInput } from '@/lib/graphql/generated/graphql.ts'; import type { MangaIdInfo } from '@/features/manga/Manga.types.ts'; import { Chapters } from '@/features/chapter/services/Chapters.ts'; import { ALL_APP_METADATA_KEY_PREFIXES } from '@/features/metadata/Metadata.constants.ts'; -import type { MigrateMode, MigrateOptions } from '@/features/migration/Migration.types.ts'; import type { - ChapterBookmarkInfo, - ChapterDownloadInfo, - ChapterIdInfo, - ChapterNumberInfo, - ChapterReadInfo, -} from '@/features/chapter/Chapter.types.ts'; -import type { GqlMetaHolder } from '@/features/metadata/Metadata.types.ts'; + MangaToMigrate, + MangaToMigrateTo, + MigrateAction, + MigrateActionCreator, + MigrateMode, + MigrateOptions, + MigrationChapter, +} from '@/features/migration/Migration.types.ts'; import { getMetadataServerSettings } from '@/features/settings/services/ServerSettingsMetadata.ts'; import { Queue } from '@/lib/Queue.ts'; import type { TrackerIdInfo } from '@/features/tracker/Tracker.types.ts'; import { assertIsDefined } from '@/base/Asserts.ts'; -type MangaToMigrate = NonNullable; -type MangaToMigrateTo = NonNullable['manga']; - -export type MigrationChapter = ChapterIdInfo & - ChapterReadInfo & - ChapterBookmarkInfo & - ChapterNumberInfo & - ChapterDownloadInfo & - GqlMetaHolder; - -type MigrateAction = { copy: () => Promise[]; cleanup: () => Promise[] }; -type MigrateActionCreator = () => MigrateAction; - -const performMigrationAction = async (migrateAction: keyof MigrateAction, ...actions: MigrateAction[]) => - Promise.all(actions.flatMap((action) => action[migrateAction]())); - export class MangaMigration { private static trackerQueue = new Map(); @@ -94,7 +74,7 @@ export class MangaMigration { // only happens in case the copy succeeded // oxlint-disable-next-line no-await-in-loop - await performMigrationAction(migrationAction, ...actions); + await Promise.all(actions.flatMap((action) => action[migrationAction]())); } }; diff --git a/src/features/migration/Migration.types.ts b/src/features/migration/Migration.types.ts index 714d49ba..3deb5d69 100644 --- a/src/features/migration/Migration.types.ts +++ b/src/features/migration/Migration.types.ts @@ -6,7 +6,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import type { GetMigratableSourcesQuery } from '@/lib/graphql/generated/graphql.ts'; +import type { + GetMangaToMigrateQuery, + GetMangaToMigrateToFetchMutation, + GetMigratableSourcesQuery, +} from '@/lib/graphql/generated/graphql.ts'; import type { SourceDisplayNameInfo, SourceIconInfo, @@ -23,7 +27,14 @@ import type { MangaThumbnailInfo, MangaTitleInfo, } from '@/features/manga/Manga.types.ts'; -import type { ChapterNumberInfo } from '@/features/chapter/Chapter.types.ts'; +import type { + ChapterBookmarkInfo, + ChapterDownloadInfo, + ChapterIdInfo, + ChapterNumberInfo, + ChapterReadInfo, +} from '@/features/chapter/Chapter.types.ts'; +import type { GqlMetaHolder } from '@/features/metadata/Metadata.types.ts'; export enum SortBy { SOURCE_NAME, @@ -136,3 +147,18 @@ export interface SourceItem extends SourceIdInfo, SourceNameInfo, SourceLanguage export type TMigratableSource = NonNullable & { mangaCount: number; }; + +export type MangaToMigrate = NonNullable; + +export type MangaToMigrateTo = NonNullable['manga']; + +export type MigrationChapter = ChapterIdInfo & + ChapterReadInfo & + ChapterBookmarkInfo & + ChapterNumberInfo & + ChapterDownloadInfo & + GqlMetaHolder; + +export type MigrateAction = { copy: () => Promise[]; cleanup: () => Promise[] }; + +export type MigrateActionCreator = () => MigrateAction;