Extract "add chapter download" button into component
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import DownloadIcon from '@mui/icons-material/Download';
|
||||
import Box from '@mui/material/Box';
|
||||
import CardActionArea from '@mui/material/CardActionArea';
|
||||
import Card from '@mui/material/Card';
|
||||
@@ -27,6 +26,7 @@ import { Chapters } from '@/modules/chapter/services/Chapters.ts';
|
||||
import { epochToDate, timeFormatter } from '@/util/DateHelper.ts';
|
||||
import { ChapterCardThumbnail } from '@/modules/chapter/components/cards/ChapterCardThumbnail.tsx';
|
||||
import { ChapterCardMetadata } from '@/modules/chapter/components/cards/ChapterCardMetadata.tsx';
|
||||
import { ChapterDownloadButton } from '@/modules/chapter/components/buttons/ChapterDownloadButton.tsx';
|
||||
|
||||
export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryListFieldsFragment }) => {
|
||||
const { manga } = chapter;
|
||||
@@ -42,14 +42,6 @@ export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryLi
|
||||
}
|
||||
};
|
||||
|
||||
const downloadChapter = () => {
|
||||
requestManager
|
||||
.addChapterToDownloadQueue(chapter.id)
|
||||
.response.catch((e) =>
|
||||
makeToast(t('global.error.label.failed_to_save_changes'), 'error', getErrorMessage(e)),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardActionArea
|
||||
@@ -95,20 +87,7 @@ export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryLi
|
||||
</IconButton>
|
||||
</CustomTooltip>
|
||||
)}
|
||||
{download == null && !chapter.isDownloaded && (
|
||||
<CustomTooltip title={t('chapter.action.download.add.label.action')}>
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
downloadChapter();
|
||||
}}
|
||||
size="large"
|
||||
>
|
||||
<DownloadIcon />
|
||||
</IconButton>
|
||||
</CustomTooltip>
|
||||
)}
|
||||
<ChapterDownloadButton chapterId={chapter.id} isDownloaded={chapter.isDownloaded} />
|
||||
</CardContent>
|
||||
</CardActionArea>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user