@@ -107,7 +107,6 @@ pub enum ServerAvailability {
107107}
108108
109109impl StreamingServer {
110- // todo: server available
111110 // pub fn new<E: Env + 'static>(profile: &Profile, server_available: bool) -> (Self, Effects) {
112111 pub fn new < E : Env + ' static > ( profile : & Profile ) -> ( Self , Effects ) {
113112 // e.g. for iOS due to apple policies:
@@ -184,7 +183,6 @@ impl<E: Env + 'static> UpdateWithCtx<E> for StreamingServer {
184183 )
185184 } ;
186185
187- // if self.torrent.is_none() {
188186 let ( get_settings_effects, new_settings_request_effects) = if self . settings . is_err ( )
189187 {
190188 let ( get_settings_url, get_settings_effect) =
@@ -264,13 +262,21 @@ impl<E: Env + 'static> UpdateWithCtx<E> for StreamingServer {
264262 . join ( new_playback_devices_request_effects)
265263 . join ( new_network_info_request_effects)
266264 . join ( new_device_info_request_effects) ;
267- // }
268-
269- // get_heartbeat_effects
270- // .unchanged()
271- // .join(new_heartbeat_request_effects)
272265 }
273266 Msg :: Action ( Action :: StreamingServer ( ActionStreamingServer :: Reload ) ) => {
267+ let ( get_heartbeat_effects, new_heartbeat_request_effects) = {
268+ let ( get_heartbeat_url, get_heartbeat_effect) =
269+ get_heartbeat :: < E > ( & ctx. profile . settings . streaming_server_url ) ;
270+ let new_heartbeat_request = LoadableRequest :: loading ( get_heartbeat_url) ;
271+ let new_heartbeat_request_effects =
272+ eq_update ( & mut self . heartbeat_request , new_heartbeat_request) ;
273+
274+ (
275+ Effects :: one ( get_heartbeat_effect) . unchanged ( ) ,
276+ new_heartbeat_request_effects,
277+ )
278+ } ;
279+
274280 let ( get_settings_url, get_settings_effect) =
275281 get_settings :: < E > ( & ctx. profile . settings . streaming_server_url ) ;
276282 let new_settings_request = LoadableRequest :: loading ( get_settings_url) ;
@@ -298,17 +304,19 @@ impl<E: Env + 'static> UpdateWithCtx<E> for StreamingServer {
298304 let new_device_info_request_effects =
299305 eq_update ( & mut self . device_info_request , new_device_info_request) ;
300306
301- Effects :: many ( vec ! [
302- get_settings_effect,
303- get_playback_devices_effect,
304- get_network_info_effect,
305- get_device_info_effect,
306- ] )
307- . unchanged ( )
308- . join ( new_settings_request_effects)
309- . join ( new_playback_devices_request_effects)
310- . join ( new_network_info_request_effects)
311- . join ( new_device_info_request_effects)
307+ get_heartbeat_effects
308+ . join ( Effects :: many ( vec ! [
309+ get_settings_effect,
310+ get_playback_devices_effect,
311+ get_network_info_effect,
312+ get_device_info_effect,
313+ ] ) )
314+ . unchanged ( )
315+ . join ( new_heartbeat_request_effects)
316+ . join ( new_settings_request_effects)
317+ . join ( new_playback_devices_request_effects)
318+ . join ( new_network_info_request_effects)
319+ . join ( new_device_info_request_effects)
312320 }
313321 Msg :: Action ( Action :: StreamingServer ( ActionStreamingServer :: UpdateSettings (
314322 settings,
@@ -429,6 +437,17 @@ impl<E: Env + 'static> UpdateWithCtx<E> for StreamingServer {
429437 Msg :: Internal ( Internal :: ProfileChanged )
430438 if self . selected . transport_url != ctx. profile . settings . streaming_server_url =>
431439 {
440+ let ( get_heartbeat_effects, new_heartbeat_request) = {
441+ let ( get_heartbeat_url, get_heartbeat_effect) =
442+ get_heartbeat :: < E > ( & ctx. profile . settings . streaming_server_url ) ;
443+ let new_heartbeat_request = LoadableRequest :: loading ( get_heartbeat_url) ;
444+
445+ (
446+ Effects :: one ( get_heartbeat_effect) . unchanged ( ) ,
447+ new_heartbeat_request,
448+ )
449+ } ;
450+
432451 let ( get_settings_url, get_settings_effect) =
433452 get_settings :: < E > ( & ctx. profile . settings . streaming_server_url ) ;
434453 let settings_request = LoadableRequest :: loading ( get_settings_url) ;
@@ -449,8 +468,9 @@ impl<E: Env + 'static> UpdateWithCtx<E> for StreamingServer {
449468 transport_url : ctx. profile . settings . streaming_server_url . to_owned ( ) ,
450469 statistics : None ,
451470 } ;
471+ self . heartbeat_request = new_heartbeat_request;
472+ self . state = Some ( Loadable :: Loading ) ;
452473 self . settings = Loadable :: Loading ;
453- // todo: check if we should alos set these to Loading as they were missing, even though we made a request to get playback devices.
454474 self . playback_devices = Loadable :: Loading ;
455475 self . network_info = Loadable :: Loading ;
456476 self . device_info = Loadable :: Loading ;
@@ -464,12 +484,12 @@ impl<E: Env + 'static> UpdateWithCtx<E> for StreamingServer {
464484 self . torrent = None ;
465485 self . statistics = None ;
466486
467- Effects :: many ( vec ! [
487+ get_heartbeat_effects . join ( Effects :: many ( vec ! [
468488 get_settings_effect,
469489 get_playback_devices_effect,
470490 get_network_info_effect,
471491 get_device_info_effect,
472- ] )
492+ ] ) )
473493 }
474494 Msg :: Internal ( Internal :: StreamingServerSettingsResult ( url, result) )
475495 if self . selected . transport_url == * url
0 commit comments