Correctly change the category of a manga from the library (#560)
For a single manga the "mangaId" should be passed while "mangaIds" is empty, however, the "mangaIds" were passed as an empty array which caused an empty array of manga ids to be passed with the mutation
This commit is contained in:
@@ -40,12 +40,19 @@ type Props =
|
|||||||
| (BaseProps & SingleModeProps & PropertiesNever<SelectModeProps>)
|
| (BaseProps & SingleModeProps & PropertiesNever<SelectModeProps>)
|
||||||
| (BaseProps & PropertiesNever<SingleModeProps> & SelectModeProps);
|
| (BaseProps & PropertiesNever<SingleModeProps> & SelectModeProps);
|
||||||
|
|
||||||
export const MangaActionMenuItems = ({ manga, handleSelection, selectedMangas = [], onClose, setHideMenu }: Props) => {
|
export const MangaActionMenuItems = ({
|
||||||
|
manga,
|
||||||
|
handleSelection,
|
||||||
|
selectedMangas: passedSelectedMangas,
|
||||||
|
onClose,
|
||||||
|
setHideMenu,
|
||||||
|
}: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [isCategorySelectOpen, setIsCategorySelectOpen] = useState(false);
|
const [isCategorySelectOpen, setIsCategorySelectOpen] = useState(false);
|
||||||
|
|
||||||
const isSingleMode = !!manga;
|
const isSingleMode = !!manga;
|
||||||
|
const selectedMangas = passedSelectedMangas ?? [];
|
||||||
|
|
||||||
const getMenuItemTitle = createGetMenuItemTitle(isSingleMode, actionToTranslationKey);
|
const getMenuItemTitle = createGetMenuItemTitle(isSingleMode, actionToTranslationKey);
|
||||||
const shouldShowMenuItem = createShouldShowMenuItem(isSingleMode);
|
const shouldShowMenuItem = createShouldShowMenuItem(isSingleMode);
|
||||||
@@ -62,6 +69,7 @@ export const MangaActionMenuItems = ({ manga, handleSelection, selectedMangas =
|
|||||||
};
|
};
|
||||||
|
|
||||||
const performAction = (action: MangaAction, mangas: TManga[]) => {
|
const performAction = (action: MangaAction, mangas: TManga[]) => {
|
||||||
|
console.log('MangaActionMenuItem', manga);
|
||||||
Mangas.performAction(action, manga ? [manga.id] : Mangas.getIds(mangas), {
|
Mangas.performAction(action, manga ? [manga.id] : Mangas.getIds(mangas), {
|
||||||
wasManuallyMarkedAsRead: true,
|
wasManuallyMarkedAsRead: true,
|
||||||
}).catch(defaultPromiseErrorHandler(`MangaActionMenuItems:performAction(${action})`));
|
}).catch(defaultPromiseErrorHandler(`MangaActionMenuItems:performAction(${action})`));
|
||||||
@@ -143,7 +151,7 @@ export const MangaActionMenuItems = ({ manga, handleSelection, selectedMangas =
|
|||||||
onClose(true);
|
onClose(true);
|
||||||
}}
|
}}
|
||||||
mangaId={manga?.id as undefined} // either mangaId or mangaIds is undefined, however, ts is not able to infer it correctly and raises an error
|
mangaId={manga?.id as undefined} // either mangaId or mangaIds is undefined, however, ts is not able to infer it correctly and raises an error
|
||||||
mangaIds={Mangas.getIds(selectedMangas)}
|
mangaIds={(passedSelectedMangas ? Mangas.getIds(selectedMangas) : undefined) as number[]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user