diff --git a/src/modules/chapter/components/actions/ChapterActionMenuItems.tsx b/src/modules/chapter/components/actions/ChapterActionMenuItems.tsx index 2704352e..fe39ac00 100644 --- a/src/modules/chapter/components/actions/ChapterActionMenuItems.tsx +++ b/src/modules/chapter/components/actions/ChapterActionMenuItems.tsx @@ -19,7 +19,7 @@ import { ComponentProps, useMemo } from 'react'; import LaunchIcon from '@mui/icons-material/Launch'; import { SelectableCollectionReturnType } from '@/modules/collection/hooks/useSelectableCollection.ts'; import { - actionToTranslationKey, + CHAPTER_ACTION_TO_TRANSLATION, ChapterAction, ChapterBookmarkInfo, ChapterDownloadInfo, @@ -92,7 +92,7 @@ export const ChapterActionMenuItems = ({ settings: { deleteChaptersWithBookmark }, } = useMetadataServerSettings(); - const getMenuItemTitle = createGetMenuItemTitle(isSingleMode, actionToTranslationKey); + const getMenuItemTitle = createGetMenuItemTitle(isSingleMode, CHAPTER_ACTION_TO_TRANSLATION); const shouldShowMenuItem = createShouldShowMenuItem(isSingleMode); const isMenuItemDisabled = createIsMenuItemDisabled(isSingleMode); diff --git a/src/modules/chapter/services/Chapters.ts b/src/modules/chapter/services/Chapters.ts index 5d1cb7d8..ceb44af7 100644 --- a/src/modules/chapter/services/Chapters.ts +++ b/src/modules/chapter/services/Chapters.ts @@ -30,7 +30,7 @@ import { epochToDate, getDateString } from '@/util/DateHelper.ts'; export type ChapterAction = 'download' | 'delete' | 'bookmark' | 'unbookmark' | 'mark_as_read' | 'mark_as_unread'; -export const actionToTranslationKey: { +export const CHAPTER_ACTION_TO_TRANSLATION: { [key in ChapterAction]: { action: { single: TranslationKey; @@ -318,10 +318,10 @@ export class Chapters { ): Promise { try { await fnToExecute(); - makeToast(translate(actionToTranslationKey[action].success, { count: itemCount }), 'success'); + makeToast(translate(CHAPTER_ACTION_TO_TRANSLATION[action].success, { count: itemCount }), 'success'); } catch (e) { makeToast( - translate(actionToTranslationKey[action].error, { count: itemCount }), + translate(CHAPTER_ACTION_TO_TRANSLATION[action].error, { count: itemCount }), 'error', getErrorMessage(e), ); diff --git a/src/modules/library/components/LibraryOptionsPanel.tsx b/src/modules/library/components/LibraryOptionsPanel.tsx index e192767a..98ffcd44 100644 --- a/src/modules/library/components/LibraryOptionsPanel.tsx +++ b/src/modules/library/components/LibraryOptionsPanel.tsx @@ -28,7 +28,7 @@ import { import { TranslationKey } from '@/Base.types.ts'; import { LibrarySortMode } from '@/modules/library/Library.types.ts'; import { CategoryMetadataInfo } from '@/modules/category/Category.types.ts'; -import { statusToTranslationKey } from '@/modules/manga/Manga.constants.ts'; +import { MANGA_STATUS_TO_TRANSLATION } from '@/modules/manga/Manga.constants.ts'; import { GridLayout } from '@/modules/core/Core.types.ts'; import { getErrorMessage } from '@/lib/HelperFunctions.ts'; @@ -113,7 +113,7 @@ export const LibraryOptionsPanel = ({ {Object.values(MangaStatus).map((status) => ( updateCategoryLibraryOptions('hasStatus', { diff --git a/src/modules/manga/Manga.constants.ts b/src/modules/manga/Manga.constants.ts index 99018c05..ee04dfe2 100644 --- a/src/modules/manga/Manga.constants.ts +++ b/src/modules/manga/Manga.constants.ts @@ -16,7 +16,7 @@ export const GLOBAL_READER_SETTINGS_MANGA: MangaIdInfo = { id: -2 }; export const MANGA_COVER_ASPECT_RATIO = '1 / 1.5'; -export const statusToTranslationKey: Record = { +export const MANGA_STATUS_TO_TRANSLATION: Record = { [MangaStatus.Cancelled]: 'manga.status.cancelled', [MangaStatus.Completed]: 'manga.status.completed', [MangaStatus.Licensed]: 'manga.status.licensed', @@ -26,7 +26,7 @@ export const statusToTranslationKey: Record = { [MangaStatus.Unknown]: 'manga.status.unknown', }; -export const actionToTranslationKey: { +export const MANGA_ACTION_TO_TRANSLATION: { [key in MangaAction]: { action: { single: TranslationKey; diff --git a/src/modules/manga/components/MangaActionMenuItems.tsx b/src/modules/manga/components/MangaActionMenuItems.tsx index b5db1c6d..c514b7c1 100644 --- a/src/modules/manga/components/MangaActionMenuItems.tsx +++ b/src/modules/manga/components/MangaActionMenuItems.tsx @@ -34,7 +34,7 @@ import { ChaptersDownloadActionMenuItems } from '@/modules/chapter/components/ac import { NestedMenuItem } from '@/modules/core/components/menu/NestedMenuItem.tsx'; import { MangaChapterStatFieldsFragment, MangaType } from '@/lib/graphql/generated/graphql.ts'; import { MangaAction, MangaDownloadInfo, MangaIdInfo, MangaUnreadInfo } from '@/modules/manga/Manga.types.ts'; -import { actionToTranslationKey } from '@/modules/manga/Manga.constants.ts'; +import { MANGA_ACTION_TO_TRANSLATION } from '@/modules/manga/Manga.constants.ts'; import { AppRoutes } from '@/modules/core/AppRoute.constants.ts'; const ACTION_DISABLES_SELECTION_MODE: MangaAction[] = ['remove_from_library'] as const; @@ -68,7 +68,7 @@ export const MangaActionMenuItems = ({ const isSingleMode = !!manga; const selectedMangas = passedSelectedMangas ?? []; - const getMenuItemTitle = createGetMenuItemTitle(isSingleMode, actionToTranslationKey); + const getMenuItemTitle = createGetMenuItemTitle(isSingleMode, MANGA_ACTION_TO_TRANSLATION); const shouldShowMenuItem = createShouldShowMenuItem(isSingleMode); const isMenuItemDisabled = createIsMenuItemDisabled(isSingleMode); diff --git a/src/modules/manga/components/MangaDetails.tsx b/src/modules/manga/components/MangaDetails.tsx index 5530074c..b6787a1e 100644 --- a/src/modules/manga/components/MangaDetails.tsx +++ b/src/modules/manga/components/MangaDetails.tsx @@ -42,7 +42,7 @@ import { MangaType, SourceType } from '@/lib/graphql/generated/graphql.ts'; import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx'; import { useResizeObserver } from '@/modules/core/hooks/useResizeObserver.tsx'; import { useMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts'; -import { MANGA_COVER_ASPECT_RATIO, statusToTranslationKey } from '@/modules/manga/Manga.constants.ts'; +import { MANGA_COVER_ASPECT_RATIO, MANGA_STATUS_TO_TRANSLATION } from '@/modules/manga/Manga.constants.ts'; import { MangaThumbnailInfo, MangaTrackRecordInfo } from '@/modules/manga/Manga.types.ts'; import { TAppThemeContext, useAppThemeContext } from '@/modules/theme/contexts/AppThemeContext.tsx'; import { applyStyles } from '@/modules/core/utils/ApplyStyles.ts'; @@ -418,7 +418,10 @@ export const MangaDetails = ({ - + diff --git a/src/modules/manga/services/Mangas.ts b/src/modules/manga/services/Mangas.ts index 5a2efd0d..a775905c 100644 --- a/src/modules/manga/services/Mangas.ts +++ b/src/modules/manga/services/Mangas.ts @@ -38,7 +38,7 @@ import { MigrateMode, } from '@/modules/manga/Manga.types.ts'; import { - actionToTranslationKey, + MANGA_ACTION_TO_TRANSLATION, MANGA_TAGS_BY_MANGA_TYPE, SOURCES_BY_MANGA_TYPE, } from '@/modules/manga/Manga.constants.ts'; @@ -494,10 +494,10 @@ export class Mangas { ): Promise { try { await fnToExecute(); - makeToast(translate(actionToTranslationKey[action].success, { count: itemCount }), 'success'); + makeToast(translate(MANGA_ACTION_TO_TRANSLATION[action].success, { count: itemCount }), 'success'); } catch (e) { makeToast( - translate(actionToTranslationKey[action].error, { count: itemCount }), + translate(MANGA_ACTION_TO_TRANSLATION[action].error, { count: itemCount }), 'error', getErrorMessage(e), ); diff --git a/src/modules/reader/components/overlay/navigation/ReaderBookmarkButton.tsx b/src/modules/reader/components/overlay/navigation/ReaderBookmarkButton.tsx index 775abd63..6fa7986a 100644 --- a/src/modules/reader/components/overlay/navigation/ReaderBookmarkButton.tsx +++ b/src/modules/reader/components/overlay/navigation/ReaderBookmarkButton.tsx @@ -12,7 +12,7 @@ import { memo } from 'react'; import BookmarkIcon from '@mui/icons-material/Bookmark'; import BookmarkBorderIcon from '@mui/icons-material/BookmarkBorder'; import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx'; -import { actionToTranslationKey, ChapterAction, Chapters } from '@/modules/chapter/services/Chapters.ts'; +import { CHAPTER_ACTION_TO_TRANSLATION, ChapterAction, Chapters } from '@/modules/chapter/services/Chapters.ts'; import { TChapterReader } from '@/modules/chapter/Chapter.types.ts'; const BaseReaderBookmarkButton = ({ id, isBookmarked }: Pick) => { @@ -21,7 +21,7 @@ const BaseReaderBookmarkButton = ({ id, isBookmarked }: Pick = isBookmarked ? 'unbookmark' : 'bookmark'; return ( - + Chapters.performAction(bookmarkAction, [id], {})} color="inherit"> {isBookmarked ? : } diff --git a/src/modules/reader/components/overlay/navigation/desktop/ReaderNavBarDesktopActions.tsx b/src/modules/reader/components/overlay/navigation/desktop/ReaderNavBarDesktopActions.tsx index 744d982b..7db0e18e 100644 --- a/src/modules/reader/components/overlay/navigation/desktop/ReaderNavBarDesktopActions.tsx +++ b/src/modules/reader/components/overlay/navigation/desktop/ReaderNavBarDesktopActions.tsx @@ -15,7 +15,7 @@ import ReplayIcon from '@mui/icons-material/Replay'; import { memo, useMemo, useRef } from 'react'; import DeleteIcon from '@mui/icons-material/Delete'; import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx'; -import { actionToTranslationKey, Chapters } from '@/modules/chapter/services/Chapters.ts'; +import { CHAPTER_ACTION_TO_TRANSLATION, Chapters } from '@/modules/chapter/services/Chapters.ts'; import { ReaderStateChapters } from '@/modules/reader/types/Reader.types.ts'; import { DownloadStateIndicator } from '@/modules/core/components/downloads/DownloadStateIndicator.tsx'; import { ReaderStatePages } from '@/modules/reader/types/ReaderProgressBar.types.ts'; @@ -33,7 +33,7 @@ const DownloadButton = ({ currentChapter }: Required + Chapters.performAction('delete', [currentChapter.id], {})} color="inherit"> @@ -46,7 +46,7 @@ const DownloadButton = ({ currentChapter }: Required + Chapters.performAction('download', [currentChapter?.id ?? -1], {})}