Skip to content

Commit

Permalink
remove Option from StreamStateChanged messages
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeastLT committed Nov 7, 2023
1 parent 6c09576 commit 582d01f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/models/ctx/update_streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn update_streams<E: Env + 'static>(
match steam_item {
Some(item) => {
let new_stream_item = StreamsItem {
state: state.clone(),
state: Some(state.to_owned()),
..item
};
streams.items.insert(key, new_stream_item);
Expand Down
18 changes: 11 additions & 7 deletions src/models/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
video_params_effects.join(subtitles_effects)
}
Msg::Action(Action::Player(ActionPlayer::StreamStateChanged { state })) => {
let stream_state_effects = eq_update(&mut self.stream_state, state.to_owned());
let stream_state_effects =
eq_update(&mut self.stream_state, Some(state.to_owned()));
let state_changed_effects =
Effects::msg(Msg::Internal(Internal::StreamStateChanged {
state: state.to_owned(),
Expand Down Expand Up @@ -631,12 +632,15 @@ fn stream_state_update(
let next_state = streams
.last_stream_item(video_id, meta_item)
.and_then(|item| item.adjusted_state(stream));
let state_changed_effect = Effects::msg(Msg::Internal(Internal::StreamStateChanged {
state: next_state.to_owned(),
stream_request: Some(stream_request.to_owned()),
meta_request: Some(meta_request.to_owned()),
}))
.unchanged();
let state_changed_effect = match &next_state {
Some(state) => Effects::msg(Msg::Internal(Internal::StreamStateChanged {
state: state.clone(),
stream_request: Some(stream_request.to_owned()),
meta_request: Some(meta_request.to_owned()),
}))
.unchanged(),
None => Effects::none().unchanged(),
};
eq_update(state, next_state).join(state_changed_effect)
}
_ => Effects::none().unchanged(),
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/msg/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub enum ActionPlayer {
video_params: Option<VideoParams>,
},
StreamStateChanged {
state: Option<StreamItemState>,
state: StreamItemState,
},
TimeChanged {
time: u64,
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/msg/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum Internal {
},
/// Dispatched when stream item's state has changed
StreamStateChanged {
state: Option<StreamItemState>,
state: StreamItemState,
stream_request: Option<ResourceRequest>,
meta_request: Option<ResourceRequest>,
},
Expand Down

0 comments on commit 582d01f

Please sign in to comment.