@@ -3,10 +3,10 @@ import Badge from '@app/components/Common/Badge';
33import CachedImage from '@app/components/Common/CachedImage' ;
44import LoadingSpinner from '@app/components/Common/LoadingSpinner' ;
55import { MetadataProviderType } from '@app/components/MetadataSelector' ;
6+ import useSettings from '@app/hooks/useSettings' ;
67import globalMessages from '@app/i18n/globalMessages' ;
78import defineMessages from '@app/utils/defineMessages' ;
8- import { ANIME_KEYWORD_ID } from '@server/api/themoviedb/constants' ;
9- import type { SeasonWithEpisodes , TvDetails } from '@server/models/Tv' ;
9+ import type { SeasonWithEpisodes } from '@server/models/Tv' ;
1010import { useIntl } from 'react-intl' ;
1111import useSWR from 'swr' ;
1212
@@ -22,14 +22,10 @@ type SeasonProps = {
2222
2323const Season = ( { seasonNumber, tvId } : SeasonProps ) => {
2424 const intl = useIntl ( ) ;
25+ const settings = useSettings ( ) ;
2526 const { data, error } = useSWR < SeasonWithEpisodes > (
2627 `/api/v1/tv/${ tvId } /season/${ seasonNumber } `
2728 ) ;
28- const { data : tvData } = useSWR < TvDetails > ( `/api/v1/tv/${ tvId } ` ) ;
29- const { data : metadataSettings } = useSWR < {
30- tv : MetadataProviderType ;
31- anime : MetadataProviderType ;
32- } > ( '/api/v1/settings/metadatas' ) ;
3329
3430 if ( ! data && ! error ) {
3531 return < LoadingSpinner /> ;
@@ -39,14 +35,12 @@ const Season = ({ seasonNumber, tvId }: SeasonProps) => {
3935 return < div > { intl . formatMessage ( messages . somethingwentwrong ) } </ div > ;
4036 }
4137
42- const isAnime = tvData ?. keywords . some (
43- ( keyword ) => keyword . id === ANIME_KEYWORD_ID
44- ) ;
45- const isTvdbProvider = metadataSettings
46- ? isAnime
47- ? metadataSettings . anime === MetadataProviderType . TVDB
48- : metadataSettings . tv === MetadataProviderType . TVDB
49- : false ;
38+ const showEpisodeAvailability =
39+ settings . currentSettings . enableEpisodeAvailability &&
40+ ( settings . currentSettings . metadataSettings . tv ===
41+ MetadataProviderType . TVDB ||
42+ settings . currentSettings . metadataSettings . anime ===
43+ MetadataProviderType . TVDB ) ;
5044
5145 return (
5246 < div className = "flex flex-col justify-center divide-y divide-gray-700" >
@@ -70,7 +64,7 @@ const Season = ({ seasonNumber, tvId }: SeasonProps) => {
7064 { episode . airDate && (
7165 < AirDateBadge airDate = { episode . airDate } />
7266 ) }
73- { isTvdbProvider &&
67+ { showEpisodeAvailability &&
7468 episode . airDate &&
7569 new Date ( episode . airDate ) <= new Date ( ) &&
7670 episode . available === true && (
0 commit comments