use sorted videos in player
@@ -228,15 +228,15 @@ fn next_video_update(
content: Some(Loadable::Ready(meta_item)),
..
}),
- ) if settings.binge_watching => meta_item
- .videos
+ ) if settings.binge_watching => {
+ let sorted_videos = meta_item.videos.iter().sorted().collect::<Vec<_>>();
+ sorted_videos
.iter()
.find_position(|video| video.id == *video_id)
.and_then(|(position, current_video)| {
- meta_item
- .videos
+ sorted_videos
.get(position + 1)
- .map(|next_video| (current_video, next_video))
+ .map(|next_video| (current_video, *next_video))
})
.filter(|(current_video, next_video)| {
let current_season = current_video
@@ -252,7 +252,8 @@ fn next_video_update(
next_season != 0 || current_season == next_season
})
.map(|(_, next_video)| next_video)
- .cloned(),
+ .cloned()
+ }
_ => None,
};
eq_update(video, next_video)
