From fb0622e209c0aa34ec88e34c29b6fd3126d95071 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:11:39 +0100 Subject: [PATCH] Add chapter action to open chapter on source (#634) --- src/components/chapter/ChapterActionMenuItems.tsx | 15 ++++++++++++++- src/i18n/locale/en.json | 1 + src/lib/data/Chapters.ts | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/chapter/ChapterActionMenuItems.tsx b/src/components/chapter/ChapterActionMenuItems.tsx index 2f71f3ba..9ad03052 100644 --- a/src/components/chapter/ChapterActionMenuItems.tsx +++ b/src/components/chapter/ChapterActionMenuItems.tsx @@ -16,6 +16,7 @@ import BookmarkRemove from '@mui/icons-material/BookmarkRemove'; import BookmarkAdd from '@mui/icons-material/BookmarkAdd'; import DoneAll from '@mui/icons-material/DoneAll'; import { useMemo } from 'react'; +import PublicIcon from '@mui/icons-material/Public'; import { SelectableCollectionReturnType } from '@/components/collection/useSelectableCollection.ts'; import { actionToTranslationKey, @@ -23,6 +24,7 @@ import { ChapterBookmarkInfo, ChapterDownloadInfo, ChapterReadInfo, + ChapterRealUrlInfo, Chapters, } from '@/lib/data/Chapters.ts'; import { TChapter } from '@/typings.ts'; @@ -35,7 +37,7 @@ import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts type BaseProps = { onClose: () => void }; type SingleModeProps = { - chapter: ChapterDownloadInfo & ChapterBookmarkInfo & ChapterReadInfo; + chapter: ChapterDownloadInfo & ChapterBookmarkInfo & ChapterReadInfo & ChapterRealUrlInfo; allChapters: TChapter[]; handleSelection?: SelectableCollectionReturnType['handleSelection']; canBeDownloaded: boolean; @@ -126,6 +128,17 @@ export const ChapterActionMenuItems = ({ {isSingleMode && ( )} + {isSingleMode && ( + { + window.open(chapter!.realUrl!, '_blank', 'noopener,noreferrer'); + onClose(); + }} + title={t('chapter.action.label.open_on_source')} + /> + )} {shouldShowMenuItem(canBeDownloaded) && ( export type ChapterReadInfo = ChapterIdInfo & Pick; export type ChapterNumberInfo = ChapterIdInfo & Pick; export type ChapterScanlatorInfo = ChapterIdInfo & Pick; +export type ChapterRealUrlInfo = Pick; export class Chapters { static getIds(chapters: { id: number }[]): number[] {