From c0f45875018d532a2c875c02b3988b528a9cf744 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sun, 25 Aug 2024 21:12:20 +0200 Subject: [PATCH] fix: select season 1 --- components/series/SeasonPicker.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/series/SeasonPicker.tsx b/components/series/SeasonPicker.tsx index 9cef17a3..7f85e0f3 100644 --- a/components/series/SeasonPicker.tsx +++ b/components/series/SeasonPicker.tsx @@ -57,7 +57,10 @@ export const SeasonPicker: React.FC = ({ item }) => { useEffect(() => { if (seasons && seasons.length > 0 && seasonIndex === undefined) { - const firstSeason = seasons[0]; + const season1 = seasons.find((season: any) => season.IndexNumber === 1); + const season0 = seasons.find((season: any) => season.IndexNumber === 0); + const firstSeason = season1 || season0 || seasons[0]; + if (firstSeason.IndexNumber !== undefined) { setSeasonIndexState((prev) => ({ ...prev, @@ -66,6 +69,7 @@ export const SeasonPicker: React.FC = ({ item }) => { } } }, [seasons, seasonIndex, setSeasonIndexState, item.Id]); + const selectedSeasonId: string | null = useMemo( () => seasons?.find((season: any) => season.IndexNumber === seasonIndex)?.Id,