diff --git a/front/packages/models/src/resources/season.ts b/front/packages/models/src/resources/season.ts index d187a5e3..c4584428 100644 --- a/front/packages/models/src/resources/season.ts +++ b/front/packages/models/src/resources/season.ts @@ -44,6 +44,10 @@ export const SeasonP = ResourceP.merge(ImagesP).extend({ * The ending date of this season. */ endDate: zdate().nullable(), + /** + * The number of episodes available on kyoo of this season. + */ + episodesCount: z.number(), }); /** diff --git a/front/packages/ui/src/details/season.tsx b/front/packages/ui/src/details/season.tsx index 49678880..5e27b482 100644 --- a/front/packages/ui/src/details/season.tsx +++ b/front/packages/ui/src/details/season.tsx @@ -35,18 +35,18 @@ import { useTranslation } from "react-i18next"; import { ComponentType } from "react"; import MenuIcon from "@material-symbols/svg-400/rounded/menu-fill.svg"; +type SeasonProcessed = Season & { href: string }; + export const SeasonHeader = ({ isLoading, seasonNumber, name, seasons, - slug, }: { isLoading: boolean; seasonNumber?: number; name?: string; - seasons?: Season[]; - slug: string; + seasons?: SeasonProcessed[]; }) => { const { css } = useYoshiki(); const { t } = useTranslation(); @@ -75,8 +75,8 @@ export const SeasonHeader = ({ {seasons?.map((x) => ( ))} @@ -86,14 +86,21 @@ export const SeasonHeader = ({ ); }; -SeasonHeader.query = (slug: string): QueryIdentifier => ({ +SeasonHeader.query = (slug: string): QueryIdentifier => ({ parser: SeasonP, path: ["shows", slug, "seasons"], params: { // Fetch all seasons at one, there won't be hundred of thems anyways. limit: 0, }, - infinite: true, + infinite: { + value: true, + map: (seasons) => + seasons.reduce((acc, x) => { + if (x.episodesCount == 0) return acc; + return [...acc, { ...x, range: null, href: `/show/${slug}?season=${x.seasonNumber}` }]; + }, [] as SeasonProcessed[]), + }, }); export const EpisodeList = ({ @@ -135,7 +142,6 @@ export const EpisodeList = ({ name={sea?.name} seasonNumber={sea?.seasonNumber} seasons={seasons} - slug={slug} /> )}