Require confirmation before category deletion

closes #1118
This commit is contained in:
schroda
2026-06-17 00:39:27 +02:00
parent 0c246ade2f
commit f960bf61cf
3 changed files with 25 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- (**Reader**) Simplify changing settings in desktop sidebar - (**Reader**) Simplify changing settings in desktop sidebar
- (**Reader**) Ignore tap zone clicks while window does not have focus - (**Reader**) Ignore tap zone clicks while window does not have focus
- (**Reader**) Improve preloading pages from the previous/next chapter - (**Reader**) Improve preloading pages from the previous/next chapter
- (**Category**) Require confirmation before deleting a category
### Fixed ### Fixed

View File

@@ -19,6 +19,9 @@ import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
import { requestManager } from '@/lib/requests/RequestManager.ts'; import { requestManager } from '@/lib/requests/RequestManager.ts';
import { ListCardContent } from '@/base/components/lists/cards/ListCardContent.tsx'; import { ListCardContent } from '@/base/components/lists/cards/ListCardContent.tsx';
import type { CategoryIdInfo, CategoryNameInfo } from '@/features/category/Category.types.ts'; import type { CategoryIdInfo, CategoryNameInfo } from '@/features/category/Category.types.ts';
import { Confirmation } from '@/base/AppAwaitableComponent.ts';
import { makeToast } from '@/base/utils/Toast.ts';
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
export const CategorySettingsCard = ({ export const CategorySettingsCard = ({
category, category,
@@ -29,8 +32,17 @@ export const CategorySettingsCard = ({
}) => { }) => {
const { t } = useLingui(); const { t } = useLingui();
const deleteCategory = () => { const deleteCategory = async () => {
requestManager.deleteCategory(category.id); await Confirmation.show({
title: t`Are you sure?`,
message: t`You are about to delete category "${category.name}"`,
});
try {
await requestManager.deleteCategory(category.id).response;
} catch (e) {
makeToast(t`Could not delete category`, 'error', getErrorMessage(e));
}
}; };
return ( return (

View File

@@ -450,6 +450,7 @@ msgstr "Apply safe area padding"
msgid "Are you sure you want to abort the migration?" msgid "Are you sure you want to abort the migration?"
msgstr "Are you sure you want to abort the migration?" msgstr "Are you sure you want to abort the migration?"
#: src/features/category/components/CategorySettingsCard.tsx
#: src/features/chapter/services/Chapters.ts #: src/features/chapter/services/Chapters.ts
#: src/features/manga/hooks/useManageMangaLibraryState.tsx #: src/features/manga/hooks/useManageMangaLibraryState.tsx
#: src/features/manga/services/Mangas.ts #: src/features/manga/services/Mangas.ts
@@ -1011,6 +1012,10 @@ msgstr "Could not create category"
msgid "Could not create theme" msgid "Could not create theme"
msgstr "Could not create theme" msgstr "Could not create theme"
#: src/features/category/components/CategorySettingsCard.tsx
msgid "Could not delete category"
msgstr "Could not delete category"
#. placeholder {0}: theme.getName() #. placeholder {0}: theme.getName()
#: src/features/theme/components/ThemeList.tsx #: src/features/theme/components/ThemeList.tsx
msgid "Could not delete theme \"{0}\"" msgid "Could not delete theme \"{0}\""
@@ -3974,6 +3979,11 @@ msgstr "Yesterday at {timeString}"
msgid "Ying & Yang" msgid "Ying & Yang"
msgstr "Ying & Yang" msgstr "Ying & Yang"
#. placeholder {0}: category.name
#: src/features/category/components/CategorySettingsCard.tsx
msgid "You are about to delete category \"{0}\""
msgstr "You are about to delete category \"{0}\""
#. placeholder {0}: manga.title #. placeholder {0}: manga.title
#: src/features/manga/hooks/useManageMangaLibraryState.tsx #: src/features/manga/hooks/useManageMangaLibraryState.tsx
msgid "You are about to remove \"{0}\" from your library" msgid "You are about to remove \"{0}\" from your library"