@@ -362,22 +362,22 @@ impl Model {
362362 continue ;
363363 }
364364
365- if let Some ( id) = self . device_id_from_name ( & node_name) {
365+ if let Some ( id) = self . node_id_from_name ( & node_name) {
366366 self . set_default_sink_id ( id) ;
367- } else {
368- self . default_sink = node_name;
369367 }
368+
369+ self . default_sink = node_name;
370370 }
371371 pulse:: Event :: DefaultSource ( node_name) => {
372372 if self . default_source == node_name {
373373 continue ;
374374 }
375375
376- if let Some ( id) = self . device_id_from_name ( & node_name) {
376+ if let Some ( id) = self . node_id_from_name ( & node_name) {
377377 self . set_default_source_id ( id) ;
378- } else {
379- self . default_source = node_name;
380378 }
379+
380+ self . default_source = node_name;
381381 }
382382 pulse:: Event :: SinkMute ( mute) => {
383383 self . sink_mute = mute;
@@ -450,16 +450,18 @@ impl Model {
450450 . insert ( object_id, device. description ) ;
451451 }
452452
453- if self . active_sink_device == device. device_id {
454- self . set_default_sink_id ( object_id) ;
455- tokio:: task:: spawn ( async move {
456- wpctl:: set_default ( object_id) . await ;
457- } ) ;
458- } else if self . active_source_device == device. device_id {
459- self . set_default_source_id ( object_id) ;
460- tokio:: task:: spawn ( async move {
461- wpctl:: set_default ( object_id) . await ;
462- } ) ;
453+ if device. device_id . is_some ( ) {
454+ if self . active_sink_device == device. device_id {
455+ self . set_default_sink_id ( object_id) ;
456+ tokio:: task:: spawn ( async move {
457+ wpctl:: set_default ( object_id) . await ;
458+ } ) ;
459+ } else if self . active_source_device == device. device_id {
460+ self . set_default_source_id ( object_id) ;
461+ tokio:: task:: spawn ( async move {
462+ wpctl:: set_default ( object_id) . await ;
463+ } ) ;
464+ }
463465 }
464466 }
465467
@@ -506,7 +508,7 @@ impl Model {
506508 Task :: none ( )
507509 }
508510
509- fn device_id_from_name ( & self , name : & str ) -> Option < u32 > {
511+ fn node_id_from_name ( & self , name : & str ) -> Option < u32 > {
510512 self . device_names
511513 . iter ( )
512514 . find ( |& ( _, n) | * n == name)
0 commit comments