Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Player next_video - skip unreleased episodes #575

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/models/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
&self.video_params,
&ctx.profile.addons,
);
let next_video_effects = next_video_update(
let next_video_effects = next_video_update::<E>(
&mut self.next_video,
&self.next_stream,
&self.selected,
Expand Down Expand Up @@ -497,7 +497,7 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
None => Effects::none().unchanged(),
};

let next_video_effects = next_video_update(
let next_video_effects = next_video_update::<E>(
&mut self.next_video,
&self.next_stream,
&self.selected,
Expand Down 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this released property is not exactly accurate I'm not entirely sure whether it's a good idea not allow going to the next video based on it. Since I'd say it's best to see whether are are valid stream or not for the user. But don't have a strong opinion 🤷

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