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

@@ -30,6 +30,7 @@ import { MenuItem } from '@/components/menu/MenuItem.tsx';
import { IChapterWithMeta } from '@/components/chapter/ChapterList.tsx';
import { ChaptersWithMeta } from '@/lib/data/ChaptersWithMeta.ts';
import { createGetMenuItemTitle, createIsMenuItemDisabled, createShouldShowMenuItem } from '@/components/menu/util.ts';
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
type BaseProps = { onClose: () => void };
@@ -116,7 +117,7 @@ export const ChapterActionMenuItems = ({
Chapters.performAction(actualAction, chapter ? [chapter.id] : ChaptersWithMeta.getIds(chaptersWithMeta), {
chapters: getChapters(),
wasManuallyMarkedAsRead: true,
});
}).catch(defaultPromiseErrorHandler('ChapterActionMenuItems::performAction'));
onClose();
};

View File

@@ -29,6 +29,7 @@ import { SelectableCollectionSelectAll } from '@/components/collection/Selectabl
import { Chapters } from '@/lib/data/Chapters.ts';
import { ChaptersWithMeta } from '@/lib/data/ChaptersWithMeta.ts';
import { ChapterActionMenuItems } from '@/components/chapter/ChapterActionMenuItems.tsx';
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
const ChapterListHeader = styled(Stack)(({ theme }) => ({
margin: 8,
@@ -167,7 +168,7 @@ export const ChapterList: React.FC<IProps> = ({ manga, isRefreshing }) => {
onClick={() =>
Chapters.download(
ChaptersWithMeta.getIds(ChaptersWithMeta.getNonDownloaded(chaptersWithMeta)),
)
).catch(defaultPromiseErrorHandler('ChapterList::download'))
}
>
<DownloadIcon />

View File

@@ -229,11 +229,7 @@ export const MangaDetails: React.FC<IProps> = ({ manga }) => {
};
const removeFromLibrary = () => {
Promise.all([requestManager.updateManga(manga.id, { updateManga: { inLibrary: false } }).response])
.then(() => makeToast(t('library.info.label.removed_from_library'), 'success'))
.catch(() => {
makeToast(t('library.error.label.remove_from_library'), 'error');
});
Mangas.removeFromLibrary([manga.id]).catch(defaultPromiseErrorHandler('MangaDetails::removeFromLibrary'));
};
return (

View File

@@ -25,6 +25,7 @@ import { CheckboxInput } from '@/components/atoms/CheckboxInput.tsx';
import { useMetadataServerSettings } from '@/util/metadataServerSettings.ts';
import { convertToGqlMeta, requestUpdateServerMetadata } from '@/util/metadata.ts';
import { makeToast } from '@/components/util/Toast.tsx';
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
type BaseProps = {
open: boolean;
@@ -155,7 +156,7 @@ export function CategorySelect(props: Props) {
addToCategories,
removeFromCategories,
},
});
}).catch(defaultPromiseErrorHandler('CategorySelect::handleOk'));
};
return (