Extract "chapter metadata" into component

This commit is contained in:
schroda
2025-03-10 22:59:21 +01:00
parent ac4bdebb61
commit 35c2172355
4 changed files with 100 additions and 85 deletions

View File

@@ -19,7 +19,6 @@ import { memo } from 'react';
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
import { DownloadStateIndicator } from '@/modules/core/components/DownloadStateIndicator.tsx';
import { ChapterHistoryListFieldsFragment, DownloadState } from '@/lib/graphql/generated/graphql.ts';
import { TypographyMaxLines } from '@/modules/core/components/TypographyMaxLines.tsx';
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { makeToast } from '@/modules/core/utils/Toast.ts';
@@ -27,6 +26,7 @@ import { getErrorMessage } from '@/lib/HelperFunctions.ts';
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';
export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryListFieldsFragment }) => {
const { manga } = chapter;
@@ -75,23 +75,10 @@ export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryLi
thumbnailUrl={manga.thumbnailUrl}
thumbnailUrlLastFetched={manga.thumbnailUrlLastFetched}
/>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
flexGrow: 1,
flexShrink: 1,
wordBreak: 'break-word',
}}
>
<TypographyMaxLines variant="h6" component="h3">
{manga.title}
</TypographyMaxLines>
<TypographyMaxLines variant="caption" display="block" lines={1}>
{`${chapter.name}${timeFormatter.format(epochToDate(Number(chapter.lastReadAt)).valueOf())}`}
</TypographyMaxLines>
</Box>
<ChapterCardMetadata
title={manga.title}
secondaryText={`${chapter.name}${timeFormatter.format(epochToDate(Number(chapter.lastReadAt)).valueOf())}`}
/>
</Box>
<DownloadStateIndicator chapterId={chapter.id} />
{download?.state === DownloadState.Error && (