Skip to content

Commit

Permalink
fix: Player next_video - skip future episodes
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Dec 5, 2023
1 parent c74d1c1 commit b008e1c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/models/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,11 @@ fn stream_state_update(
eq_update(state, next_state)
}

fn next_video_update(
/// Updates the next video when:
/// 1. User has enabled Binge watching
/// and
/// 2. When the next video released date has passed (now > released)
fn next_video_update<E: Env + 'static>(
video: &mut Option<Video>,
stream: &Option<Stream>,
selected: &Option<Selected>,
Expand Down Expand Up @@ -664,12 +668,18 @@ fn next_video_update(
.unwrap_or_default();
next_season != 0 || current_season == next_season
})
.map(|(_, next_video)| {
let mut next_video = next_video.clone();
if let Some(stream) = stream {
next_video.streams = vec![stream.clone()];
.and_then(|(_, next_video)| {
match next_video.released {
Some(released) if released > E::now() => None,
// if no `released` is known or released is in the past
_ => {
let mut next_video = next_video.clone();
if let Some(stream) = stream {
next_video.streams = vec![stream.clone()];
}
Some(next_video)
}
}
next_video
}),
_ => None,
};
Expand Down

0 comments on commit b008e1c

Please sign in to comment.