Skip to content

Commit 28dbdaa

Browse files
committedFeb 28, 2025··
feat: MetaDetails selects appropriate season:
- For non-watched series it choses 1st season - For watched series it uses the LibraryItem video to choose the same season Signed-off-by: Lachezar Lechev <lachezar@ambire.com>
1 parent 24d11b4 commit 28dbdaa

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed
 

‎src/routes/MetaDetails/VideosList/VideosList.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const VideosList = ({ className, metaItem, libraryItem, season, seasonOnSelect,
2020
:
2121
[];
2222
}, [metaItem]);
23+
// Orders season from 1 to X and 0 (special season) at the end
2324
const seasons = React.useMemo(() => {
2425
return videos
2526
.map(({ season }) => season)
@@ -36,17 +37,27 @@ const VideosList = ({ className, metaItem, libraryItem, season, seasonOnSelect,
3637
return season;
3738
}
3839

40+
if (libraryItem?.state.video_id && videos) {
41+
const video = videos?.find((video) => video.id === libraryItem.state.video_id);
42+
43+
if (video && video.season && seasons.includes(video.season)) {
44+
return video.season;
45+
}
46+
}
47+
3948
const nonSpecialSeasons = seasons.filter((season) => season !== 0);
4049
if (nonSpecialSeasons.length > 0) {
41-
return nonSpecialSeasons[nonSpecialSeasons.length - 1];
50+
// default to 1st season
51+
return nonSpecialSeasons[0];
4252
}
4353

4454
if (seasons.length > 0) {
45-
return seasons[seasons.length - 1];
55+
// default to 1st season
56+
return seasons[0];
4657
}
4758

4859
return null;
49-
}, [seasons, season]);
60+
}, [seasons, season, videos, libraryItem]);
5061
const videosForSeason = React.useMemo(() => {
5162
return videos
5263
.filter((video) => {

0 commit comments

Comments
 (0)
Please sign in to comment.