2023-12-19 15:17:00 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2024-04-14 15:50:12 +02:00
|
|
|
import Button from '@mui/material/Button';
|
2023-12-19 15:17:00 +01:00
|
|
|
import PlayArrowIcon from '@mui/icons-material/PlayArrow';
|
2023-12-28 16:07:50 +01:00
|
|
|
import { Link } from 'react-router-dom';
|
2025-08-16 02:48:46 +02:00
|
|
|
import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
|
2025-08-15 22:02:58 +02:00
|
|
|
import { Chapters } from '@/features/chapter/services/Chapters.ts';
|
2025-03-29 03:12:36 +01:00
|
|
|
import { MUIUtil } from '@/lib/mui/MUI.util.ts';
|
2025-08-15 22:02:58 +02:00
|
|
|
import { ChapterReadInfo, ChapterSourceOrderInfo } from '@/features/chapter/Chapter.types.ts';
|
2023-12-28 16:07:50 +01:00
|
|
|
|
2023-12-19 15:17:00 +01:00
|
|
|
export const ContinueReadingButton = ({
|
|
|
|
|
showContinueReadingButton,
|
2024-12-06 23:59:39 +01:00
|
|
|
chapter,
|
2023-12-19 15:17:00 +01:00
|
|
|
mangaLinkTo,
|
|
|
|
|
}: {
|
|
|
|
|
showContinueReadingButton: boolean;
|
2024-12-06 23:59:39 +01:00
|
|
|
chapter?: (ChapterSourceOrderInfo & ChapterReadInfo) | null;
|
2023-12-19 15:17:00 +01:00
|
|
|
mangaLinkTo: string;
|
|
|
|
|
}) => {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2024-12-06 23:59:39 +01:00
|
|
|
if (!showContinueReadingButton || !chapter) {
|
2023-12-19 15:17:00 +01:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-06 23:59:39 +01:00
|
|
|
const { sourceOrder } = chapter;
|
|
|
|
|
const isFirstChapter = sourceOrder === 1;
|
|
|
|
|
|
2023-12-19 15:17:00 +01:00
|
|
|
return (
|
2025-02-01 14:24:38 +01:00
|
|
|
<CustomTooltip title={t(isFirstChapter ? 'global.button.start' : 'global.button.resume')}>
|
2023-12-19 15:17:00 +01:00
|
|
|
<Button
|
2025-03-29 03:12:36 +01:00
|
|
|
{...MUIUtil.preventRippleProp()}
|
2023-12-19 15:17:00 +01:00
|
|
|
variant="contained"
|
|
|
|
|
size="small"
|
2024-08-30 21:19:40 +02:00
|
|
|
sx={{ minWidth: 'unset', py: 0.5, px: 0.75 }}
|
2023-12-28 16:07:50 +01:00
|
|
|
component={Link}
|
2024-12-11 20:10:59 +01:00
|
|
|
to={`${mangaLinkTo}/chapter/${chapter.sourceOrder}`}
|
2025-02-01 19:48:24 +01:00
|
|
|
state={Chapters.getReaderOpenChapterLocationState(chapter)}
|
2023-12-19 15:17:00 +01:00
|
|
|
onClick={(e) => e.stopPropagation()}
|
|
|
|
|
>
|
|
|
|
|
<PlayArrowIcon />
|
|
|
|
|
</Button>
|
2025-02-01 14:24:38 +01:00
|
|
|
</CustomTooltip>
|
2023-12-19 15:17:00 +01:00
|
|
|
);
|
|
|
|
|
};
|