mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
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>
This commit is contained in:
parent
24d11b4cf9
commit
28dbdaa20d
1 changed files with 14 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ const VideosList = ({ className, metaItem, libraryItem, season, seasonOnSelect,
|
|||
:
|
||||
[];
|
||||
}, [metaItem]);
|
||||
// Orders season from 1 to X and 0 (special season) at the end
|
||||
const seasons = React.useMemo(() => {
|
||||
return videos
|
||||
.map(({ season }) => season)
|
||||
|
|
@ -36,17 +37,27 @@ const VideosList = ({ className, metaItem, libraryItem, season, seasonOnSelect,
|
|||
return season;
|
||||
}
|
||||
|
||||
if (libraryItem?.state.video_id && videos) {
|
||||
const video = videos?.find((video) => video.id === libraryItem.state.video_id);
|
||||
|
||||
if (video && video.season && seasons.includes(video.season)) {
|
||||
return video.season;
|
||||
}
|
||||
}
|
||||
|
||||
const nonSpecialSeasons = seasons.filter((season) => season !== 0);
|
||||
if (nonSpecialSeasons.length > 0) {
|
||||
return nonSpecialSeasons[nonSpecialSeasons.length - 1];
|
||||
// default to 1st season
|
||||
return nonSpecialSeasons[0];
|
||||
}
|
||||
|
||||
if (seasons.length > 0) {
|
||||
return seasons[seasons.length - 1];
|
||||
// default to 1st season
|
||||
return seasons[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}, [seasons, season]);
|
||||
}, [seasons, season, videos, libraryItem]);
|
||||
const videosForSeason = React.useMemo(() => {
|
||||
return videos
|
||||
.filter((video) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue