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: StreamingServer statistics response null #576

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions src/models/streaming_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ impl<E: Env + 'static> UpdateWithCtx<E> for StreamingServer {
&& self.selected.statistics.as_ref() == Some(request) =>
{
let loadable = match result {
Ok(statistics) => Loadable::Ready(statistics.to_owned()),
Ok(Some(statistics)) => Loadable::Ready(statistics.to_owned()),
// we've loaded the whole stream, no need to update the statistics.
Ok(None) => return Effects::none().unchanged(),
Err(error) => Loadable::Err(error.to_owned()),
};
eq_update(&mut self.statistics, Some(loadable))
Expand Down Expand Up @@ -588,7 +590,8 @@ fn get_torrent_statistics<E: Env + 'static>(url: &Url, request: &StatisticsReque
.body(())
.expect("request builder failed");
EffectFuture::Concurrent(
E::fetch::<_, Statistics>(request)
// `null`` can be returned when the stream has been loaded 100%
elpiel marked this conversation as resolved.
Show resolved Hide resolved
E::fetch::<_, Option<Statistics>>(request)
.map(enclose!((url) move |result|
Msg::Internal(Internal::StreamingServerStatisticsResult((url, statistics_request), result))
))
Expand Down
9 changes: 6 additions & 3 deletions src/runtime/msg/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ pub enum Internal {
StreamingServerUpdateSettingsResult(Url, Result<(), EnvError>),
/// Result for creating a torrent.
StreamingServerCreateTorrentResult(String, Result<(), EnvError>),
// Result for playing on device.
/// Result for playing on device.
StreamingServerPlayOnDeviceResult(String, Result<(), EnvError>),
// Result for streaming server statistics.
StreamingServerStatisticsResult((Url, StatisticsRequest), Result<Statistics, EnvError>),
/// Result for streaming server statistics.
///
/// Server will return None (or `null`) in response for [`Statistics`]`,
/// when stream has been fully loaded up to 100%
StreamingServerStatisticsResult((Url, StatisticsRequest), Result<Option<Statistics>, EnvError>),
/// Result for fetching resource from addons.
ResourceRequestResult(ResourceRequest, Box<Result<ResourceResponse, EnvError>>),
/// Result for fetching manifest from addon.
Expand Down