From f8e1bfc401ac4869e8d5e790d526cfa059680a42 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 17 Jan 2024 13:46:05 +0100 Subject: [PATCH] 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 --- src/components/manga/MangaActionMenuItems.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/manga/MangaActionMenuItems.tsx b/src/components/manga/MangaActionMenuItems.tsx index cb7c0939..8046d7f9 100644 --- a/src/components/manga/MangaActionMenuItems.tsx +++ b/src/components/manga/MangaActionMenuItems.tsx @@ -40,12 +40,19 @@ type Props = | (BaseProps & SingleModeProps & PropertiesNever) | (BaseProps & PropertiesNever & SelectModeProps); -export const MangaActionMenuItems = ({ manga, handleSelection, selectedMangas = [], onClose, setHideMenu }: Props) => { +export const MangaActionMenuItems = ({ + manga, + handleSelection, + selectedMangas: passedSelectedMangas, + onClose, + setHideMenu, +}: Props) => { const { t } = useTranslation(); const [isCategorySelectOpen, setIsCategorySelectOpen] = useState(false); const isSingleMode = !!manga; + const selectedMangas = passedSelectedMangas ?? []; const getMenuItemTitle = createGetMenuItemTitle(isSingleMode, actionToTranslationKey); const shouldShowMenuItem = createShouldShowMenuItem(isSingleMode); @@ -62,6 +69,7 @@ export const MangaActionMenuItems = ({ manga, handleSelection, selectedMangas = }; const performAction = (action: MangaAction, mangas: TManga[]) => { + console.log('MangaActionMenuItem', manga); Mangas.performAction(action, manga ? [manga.id] : Mangas.getIds(mangas), { wasManuallyMarkedAsRead: true, }).catch(defaultPromiseErrorHandler(`MangaActionMenuItems:performAction(${action})`)); @@ -143,7 +151,7 @@ export const MangaActionMenuItems = ({ manga, handleSelection, selectedMangas = 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 - mangaIds={Mangas.getIds(selectedMangas)} + mangaIds={(passedSelectedMangas ? Mangas.getIds(selectedMangas) : undefined) as number[]} /> )}