From 4386772404de469d3980252fc38aa327a95846a6 Mon Sep 17 00:00:00 2001 From: Honkertonken <94032937+Honkertonken@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:27:05 +0530 Subject: [PATCH] Update MediaCard.tsx --- src/components/media/MediaCard.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/media/MediaCard.tsx b/src/components/media/MediaCard.tsx index ac6c243c..ce4eeffe 100644 --- a/src/components/media/MediaCard.tsx +++ b/src/components/media/MediaCard.tsx @@ -35,13 +35,15 @@ function MediaCardContent({ const { t } = useTranslation(); const percentageString = `${Math.round(percentage ?? 0).toFixed(0)}%`; - const canLink = linkable && !closable && !!media.year; + const currentYear = new Date().getFullYear(); + const isReleased = media.year && media.year < currentYear; + const canLink = linkable && !closable && isReleased; const dotListContent = [t(`media.types.${media.type}`)]; - if (media.year) { + if (isReleased) { dotListContent.push(media.year.toFixed()); } else { - dotListContent.push(t("Unreleased")); + dotListContent.push(t("media.unreleased")); } return ( @@ -146,7 +148,9 @@ function MediaCardContent({ export function MediaCard(props: MediaCardProps) { const content = ; - const canLink = props.linkable && !props.closable; + const currentYear = new Date().getFullYear(); + const isReleased = props.media.year && props.media.year < currentYear; + const canLink = props.linkable && !props.closable && isReleased; let link = canLink ? `/media/${encodeURIComponent(mediaItemToId(props.media))}` @@ -161,7 +165,7 @@ export function MediaCard(props: MediaCardProps) { } } - if (!props.linkable || !props.media.year) return {content}; + if (!canLink) return {content}; return (