From 528412b9517dddab8e9abf89849ab454b5310b8d Mon Sep 17 00:00:00 2001 From: Foowy <49217685+Foowy@users.noreply.github.com> Date: Mon, 3 Aug 2026 15:24:14 +0000 Subject: [PATCH] refactor(tmdb): support DateKindaMatches rating, convert MatchRatingType to string union MatchRatingType is now a string union instead of an enum, per harshithmohan's review on ShokoAnime/ShokoServer#1389. Adds the DateKindaMatches rating (server-side last-resort nearest-air-date fallback) to the abbreviation/color mapping and the "Approximate" count bucket. --- .../Collection/Tmdb/MatchRating.tsx | 34 ++++++++++--------- src/components/Collection/Tmdb/TopPanel.tsx | 6 ++-- src/core/types/api/episode.ts | 20 +++++------ src/pages/collection/series/TmdbLinking.tsx | 4 +-- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/components/Collection/Tmdb/MatchRating.tsx b/src/components/Collection/Tmdb/MatchRating.tsx index 0485358d0..03398de36 100644 --- a/src/components/Collection/Tmdb/MatchRating.tsx +++ b/src/components/Collection/Tmdb/MatchRating.tsx @@ -1,22 +1,24 @@ import cx from 'classnames'; -import { MatchRatingType } from '@/core/types/api/episode'; +import type { MatchRatingType } from '@/core/types/api/episode'; const getAbbreviation = (rating?: MatchRatingType) => { switch (rating) { - case MatchRatingType.DateAndTitleMatches: + case 'DateAndTitleMatches': return ['DT', 'Date & Title']; - case MatchRatingType.DateAndTitleKindaMatches: + case 'DateAndTitleKindaMatches': return ['~DT', 'Date & Approx. Title']; - case MatchRatingType.DateMatches: + case 'DateMatches': return ['D', 'Date']; - case MatchRatingType.TitleMatches: + case 'TitleMatches': return ['T', 'Title']; - case MatchRatingType.TitleKindaMatches: + case 'TitleKindaMatches': return ['~T', 'Approx. Title']; - case MatchRatingType.UserVerified: + case 'DateKindaMatches': + return ['~D', 'Approx. Date']; + case 'UserVerified': return ['UO', 'User Override']; - case MatchRatingType.FirstAvailable: + case 'FirstAvailable': return ['BG', 'Best Guess']; default: return ['', '']; @@ -34,14 +36,14 @@ const MatchRating = ({ isDisabled, isOdd, rating }: Props) => ( className={cx( 'flex w-16 items-center justify-center rounded-md border border-panel-border text-button-primary-text', { - 'bg-panel-text-important': rating === MatchRatingType.DateAndTitleMatches - || rating === MatchRatingType.TitleMatches, - 'bg-panel-text-warning': rating === MatchRatingType.DateMatches || rating === MatchRatingType.TitleKindaMatches - || rating === MatchRatingType.DateAndTitleKindaMatches, - 'bg-panel-text-primary': rating === MatchRatingType.UserVerified, - 'bg-panel-text-danger': rating === MatchRatingType.FirstAvailable, - 'bg-panel-background': (!rating || rating === MatchRatingType.None) && !isOdd, - 'bg-panel-background-alt': (!rating || rating === MatchRatingType.None) && isOdd, + 'bg-panel-text-important': rating === 'DateAndTitleMatches' + || rating === 'TitleMatches', + 'bg-panel-text-warning': rating === 'DateMatches' || rating === 'TitleKindaMatches' + || rating === 'DateAndTitleKindaMatches' || rating === 'DateKindaMatches', + 'bg-panel-text-primary': rating === 'UserVerified', + 'bg-panel-text-danger': rating === 'FirstAvailable', + 'bg-panel-background': (!rating || rating === 'None') && !isOdd, + 'bg-panel-background-alt': (!rating || rating === 'None') && isOdd, 'opacity-65': isDisabled, }, )} diff --git a/src/components/Collection/Tmdb/TopPanel.tsx b/src/components/Collection/Tmdb/TopPanel.tsx index 4f8c6cc91..79e4993ed 100644 --- a/src/components/Collection/Tmdb/TopPanel.tsx +++ b/src/components/Collection/Tmdb/TopPanel.tsx @@ -7,9 +7,9 @@ import { countBy, filter, flatMap } from 'lodash'; import Button from '@/components/Input/Button'; import ShokoPanel from '@/components/Panels/ShokoPanel'; import ItemCount from '@/components/Utilities/ItemCount'; -import { MatchRatingType } from '@/core/types/api/episode'; import useNavigateVoid from '@/hooks/useNavigateVoid'; +import type { MatchRatingType } from '@/core/types/api/episode'; import type { TmdbEpisodeXrefType } from '@/core/types/api/tmdb'; type Props = { @@ -30,7 +30,7 @@ const TopPanel = (props: Props) => { if (!xrefs) return undefined; return filter( flatMap(xrefs, xref => xref), - xref => xref.Rating !== MatchRatingType.None, + xref => xref.Rating !== 'None', ); }, [xrefs], @@ -65,7 +65,7 @@ const TopPanel = (props: Props) => {