Optionally remove migrated manga from categories

In case the setting is enabled, the manga should be removed from all categories on migration
This commit is contained in:
schroda
2024-06-26 14:04:42 +02:00
parent 6224ad4596
commit c337ec09ea

View File

@@ -440,7 +440,8 @@ export class Mangas {
}: Omit<MigrateOptions, 'mangaIdToMigrateTo'>, }: Omit<MigrateOptions, 'mangaIdToMigrateTo'>,
): Promise<void> { ): Promise<void> {
return Mangas.executeAction('migrate', 1, async () => { return Mangas.executeAction('migrate', 1, async () => {
const [{ data: mangaToMigrateData }, { data: mangaToMigrateToData }] = await Promise.all([ const [{ data: mangaToMigrateData }, { data: mangaToMigrateToData }, { removeMangaFromCategories }] =
await Promise.all([
requestManager.getMangaToMigrate(mangaId, { requestManager.getMangaToMigrate(mangaId, {
migrateChapters, migrateChapters,
migrateCategories, migrateCategories,
@@ -452,6 +453,7 @@ export class Mangas {
migrateCategories, migrateCategories,
migrateTracking, migrateTracking,
}).response, }).response,
getMetadataServerSettings(),
]); ]);
if (!mangaToMigrateData.manga || !mangaToMigrateToData?.fetchManga?.manga) { if (!mangaToMigrateData.manga || !mangaToMigrateToData?.fetchManga?.manga) {
@@ -482,7 +484,10 @@ export class Mangas {
? requestManager.updateManga(mangaIdToMigrateTo, { updateManga: { inLibrary: true } }).response ? requestManager.updateManga(mangaIdToMigrateTo, { updateManga: { inLibrary: true } }).response
: undefined, : undefined,
mode === 'migrate' mode === 'migrate'
? requestManager.updateManga(mangaId, { updateManga: { inLibrary: false } }).response ? requestManager.updateManga(mangaId, {
updateManga: { inLibrary: false },
updateMangaCategories: removeMangaFromCategories ? { clearCategories: true } : undefined,
}).response
: undefined, : undefined,
]); ]);
}); });