Fix/add manga to library without dialog not adding default categories (#632)

* Add default categories when adding manga to library without dialog

* Add manga to library and update categories in one mutation
This commit is contained in:
schroda
2024-03-02 15:26:15 +01:00
committed by GitHub
parent eb233aef3d
commit c5a5c4b8af
6 changed files with 40 additions and 15 deletions

View File

@@ -28,7 +28,7 @@ import { makeToast } from '@/components/util/Toast.tsx';
type BaseProps = {
open: boolean;
onClose: (didUpdateCategories: boolean) => void;
onClose: (didUpdateCategories: boolean, addToCategories?: number[], removeFromCategories?: number[]) => void;
};
type SingleMangaModeProps = {
@@ -125,8 +125,6 @@ export function CategorySelect(props: Props) {
};
const handleOk = () => {
onClose(true);
const addToCategories = isSingleSelectionMode
? categoriesToAdd.filter((categoryId) => !mangaCategoryIds.includes(categoryId))
: categoriesToAdd;
@@ -134,6 +132,8 @@ export function CategorySelect(props: Props) {
? mangaCategoryIds.filter((categoryId) => !categoriesToAdd.includes(categoryId))
: categoriesToRemove;
onClose(true, addToCategories, removeFromCategories);
if (doNotShowAddToLibraryDialogAgain) {
requestUpdateServerMetadata(convertToGqlMeta(serverMetadata)! ?? {}, [
['showAddToLibraryCategorySelectDialog', false],
@@ -145,6 +145,11 @@ export function CategorySelect(props: Props) {
return;
}
if (addToLibrary) {
// categories get updated in MangaDetails
return;
}
Mangas.performAction('change_categories', mangaIds, {
changeCategoriesPatch: {
addToCategories,