From 7a048828310dbf1886dfdb929b5697c81e6d3de4 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Mon, 12 Aug 2024 20:24:24 +0300 Subject: [PATCH] Fixed: Avoid displaying multi-languages for episodes parsed without languages --- frontend/src/Activity/History/HistoryRow.tsx | 3 +- ...isodeLanguages.js => EpisodeLanguages.tsx} | 41 +++++++------------ 2 files changed, 16 insertions(+), 28 deletions(-) rename frontend/src/Episode/{EpisodeLanguages.js => EpisodeLanguages.tsx} (60%) diff --git a/frontend/src/Activity/History/HistoryRow.tsx b/frontend/src/Activity/History/HistoryRow.tsx index bcd84f606..f73cf66ef 100644 --- a/frontend/src/Activity/History/HistoryRow.tsx +++ b/frontend/src/Activity/History/HistoryRow.tsx @@ -15,6 +15,7 @@ import SeasonEpisodeNumber from 'Episode/SeasonEpisodeNumber'; import useEpisode from 'Episode/useEpisode'; import usePrevious from 'Helpers/Hooks/usePrevious'; import { icons, tooltipPositions } from 'Helpers/Props'; +import Language from 'Language/Language'; import { QualityModel } from 'Quality/Quality'; import SeriesTitleLink from 'Series/SeriesTitleLink'; import useSeries from 'Series/useSeries'; @@ -31,7 +32,7 @@ interface HistoryRowProps { id: number; episodeId: number; seriesId: number; - languages: object[]; + languages: Language[]; quality: QualityModel; customFormats?: CustomFormat[]; customFormatScore: number; diff --git a/frontend/src/Episode/EpisodeLanguages.js b/frontend/src/Episode/EpisodeLanguages.tsx similarity index 60% rename from frontend/src/Episode/EpisodeLanguages.js rename to frontend/src/Episode/EpisodeLanguages.tsx index 66f278897..1812d0394 100644 --- a/frontend/src/Episode/EpisodeLanguages.js +++ b/frontend/src/Episode/EpisodeLanguages.tsx @@ -1,18 +1,21 @@ -import PropTypes from 'prop-types'; import React from 'react'; import Label from 'Components/Label'; import Popover from 'Components/Tooltip/Popover'; import { kinds, tooltipPositions } from 'Helpers/Props'; +import Language from 'Language/Language'; import translate from 'Utilities/String/translate'; -function EpisodeLanguages(props) { - const { - className, - languages, - isCutoffNotMet - } = props; +interface EpisodeLanguagesProps { + className?: string; + languages: Language[]; + isCutoffNotMet?: boolean; +} - if (!languages) { +function EpisodeLanguages(props: EpisodeLanguagesProps) { + const { className, languages, isCutoffNotMet = true } = props; + + // TODO: Typescript - Remove once everything is converted + if (!languages || languages.length === 0) { return null; } @@ -41,15 +44,9 @@ function EpisodeLanguages(props) { title={translate('Languages')} body={ } position={tooltipPositions.LEFT} @@ -57,14 +54,4 @@ function EpisodeLanguages(props) { ); } -EpisodeLanguages.propTypes = { - className: PropTypes.string, - languages: PropTypes.arrayOf(PropTypes.object), - isCutoffNotMet: PropTypes.bool -}; - -EpisodeLanguages.defaultProps = { - isCutoffNotMet: true -}; - export default EpisodeLanguages;