Feature/add option to remove manga from categories when removing from library (#633)

* Optionally remove manga categories when removing them from library

* Use "Mangas::removeFromLibrary"

* Handle uncatched promises
This commit is contained in:
schroda
2024-03-02 15:28:58 +01:00
committed by GitHub
parent c5a5c4b8af
commit 8bdf035ca7
12 changed files with 65 additions and 13 deletions

View File

@@ -18,6 +18,7 @@ import {
} from '@/lib/graphql/generated/graphql.ts';
import { Chapters } from '@/lib/data/Chapters.ts';
import { makeToast } from '@/components/util/Toast.tsx';
import { getMetadataServerSettings } from '@/util/metadataServerSettings.ts';
export type MangaAction =
| 'download'
@@ -208,10 +209,15 @@ export class Mangas {
}
static async removeFromLibrary(mangaIds: number[]): Promise<void> {
const { removeMangaFromCategories } = await getMetadataServerSettings();
return Mangas.executeAction(
'remove_from_library',
mangaIds.length,
() => requestManager.updateMangas(mangaIds, { inLibrary: false }).response,
() =>
requestManager.updateMangas(mangaIds, {
updateMangas: { inLibrary: false },
updateMangasCategories: removeMangaFromCategories ? { clearCategories: true } : undefined,
}).response,
);
}