From c4f68615cd2fc0efe959506e4747439ff6165f87 Mon Sep 17 00:00:00 2001 From: Honkertonken <94032937+Honkertonken@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:20:57 +0530 Subject: [PATCH 1/6] Update tmdb.ts --- src/backend/metadata/tmdb.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/backend/metadata/tmdb.ts b/src/backend/metadata/tmdb.ts index b143b312..88412c84 100644 --- a/src/backend/metadata/tmdb.ts +++ b/src/backend/metadata/tmdb.ts @@ -173,12 +173,17 @@ export async function multiSearch( language: "en-US", page: 1, }); - // filter out results that aren't movies or shows - const results = data.results.filter( - (r) => - r.media_type === TMDBContentTypes.MOVIE || - r.media_type === TMDBContentTypes.TV, - ); + const currentDate = new Date(); + // filter out results that aren't movies or shows or are unreleased + const results = data.results.filter((r) => { + if (r.media_type === TMDBContentTypes.MOVIE) { + return new Date(r.release_date) <= currentDate; + } + if (r.media_type === TMDBContentTypes.TV) { + return new Date(r.first_air_date) <= currentDate; + } + return false; + }); return results; } From e431626bfa767b5c8c1e2b328a39171b1c9d912b Mon Sep 17 00:00:00 2001 From: Honkertonken <94032937+Honkertonken@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:19:12 +0530 Subject: [PATCH 2/6] 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 cad3ae6a..ac6c243c 100644 --- a/src/components/media/MediaCard.tsx +++ b/src/components/media/MediaCard.tsx @@ -35,10 +35,14 @@ function MediaCardContent({ const { t } = useTranslation(); const percentageString = `${Math.round(percentage ?? 0).toFixed(0)}%`; - const canLink = linkable && !closable; + const canLink = linkable && !closable && !!media.year; const dotListContent = [t(`media.types.${media.type}`)]; - if (media.year) dotListContent.push(media.year.toFixed()); + if (media.year) { + dotListContent.push(media.year.toFixed()); + } else { + dotListContent.push(t("Unreleased")); + } return (
{content}; + if (!props.linkable || !props.media.year) return {content}; return ( Date: Wed, 27 Mar 2024 23:19:35 +0530 Subject: [PATCH 3/6] Revert "Update tmdb.ts" This reverts commit c4f68615cd2fc0efe959506e4747439ff6165f87. --- src/backend/metadata/tmdb.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/backend/metadata/tmdb.ts b/src/backend/metadata/tmdb.ts index 88412c84..b143b312 100644 --- a/src/backend/metadata/tmdb.ts +++ b/src/backend/metadata/tmdb.ts @@ -173,17 +173,12 @@ export async function multiSearch( language: "en-US", page: 1, }); - const currentDate = new Date(); - // filter out results that aren't movies or shows or are unreleased - const results = data.results.filter((r) => { - if (r.media_type === TMDBContentTypes.MOVIE) { - return new Date(r.release_date) <= currentDate; - } - if (r.media_type === TMDBContentTypes.TV) { - return new Date(r.first_air_date) <= currentDate; - } - return false; - }); + // filter out results that aren't movies or shows + const results = data.results.filter( + (r) => + r.media_type === TMDBContentTypes.MOVIE || + r.media_type === TMDBContentTypes.TV, + ); return results; } 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 4/6] 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 ( Date: Thu, 28 Mar 2024 13:36:56 +0530 Subject: [PATCH 5/6] Update MediaCard.tsx --- src/components/media/MediaCard.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/media/MediaCard.tsx b/src/components/media/MediaCard.tsx index ce4eeffe..937ff1c6 100644 --- a/src/components/media/MediaCard.tsx +++ b/src/components/media/MediaCard.tsx @@ -36,11 +36,11 @@ function MediaCardContent({ const percentageString = `${Math.round(percentage ?? 0).toFixed(0)}%`; const currentYear = new Date().getFullYear(); - const isReleased = media.year && media.year < currentYear; - const canLink = linkable && !closable && isReleased; + const canLink = + linkable && !closable && media.year && media.year < currentYear; const dotListContent = [t(`media.types.${media.type}`)]; - if (isReleased) { + if (media.year && media.year < currentYear) { dotListContent.push(media.year.toFixed()); } else { dotListContent.push(t("media.unreleased")); @@ -149,8 +149,11 @@ export function MediaCard(props: MediaCardProps) { const content = ; const currentYear = new Date().getFullYear(); - const isReleased = props.media.year && props.media.year < currentYear; - const canLink = props.linkable && !props.closable && isReleased; + const canLink = + props.linkable && + !props.closable && + props.media.year && + props.media.year < currentYear; let link = canLink ? `/media/${encodeURIComponent(mediaItemToId(props.media))}` From bfee71f44620e4d66e338f0f7e86303a811916c1 Mon Sep 17 00:00:00 2001 From: Honkertonken <94032937+Honkertonken@users.noreply.github.com> Date: Thu, 28 Mar 2024 16:47:18 +0530 Subject: [PATCH 6/6] Update MediaCard.tsx --- src/components/media/MediaCard.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/media/MediaCard.tsx b/src/components/media/MediaCard.tsx index 937ff1c6..563e4d9b 100644 --- a/src/components/media/MediaCard.tsx +++ b/src/components/media/MediaCard.tsx @@ -37,10 +37,12 @@ function MediaCardContent({ const currentYear = new Date().getFullYear(); const canLink = - linkable && !closable && media.year && media.year < currentYear; + linkable && !closable && media.year && media.year <= currentYear; const dotListContent = [t(`media.types.${media.type}`)]; - if (media.year && media.year < currentYear) { + if (media.year && media.year > currentYear) { + dotListContent.push(`${media.year}`, t("media.unreleased")); + } else if (media.year) { dotListContent.push(media.year.toFixed()); } else { dotListContent.push(t("media.unreleased")); @@ -153,7 +155,7 @@ export function MediaCard(props: MediaCardProps) { props.linkable && !props.closable && props.media.year && - props.media.year < currentYear; + props.media.year <= currentYear; let link = canLink ? `/media/${encodeURIComponent(mediaItemToId(props.media))}`