@@ -347,8 +347,9 @@ impl App {
347347 }
348348 }
349349 DeviceMenuOptions :: Forget => {
350- self . perform_forget_device ( & device_clone) . await ?;
351- stay_in_device_menu = false ;
350+ if self . perform_forget_device ( & device_clone) . await ? {
351+ stay_in_device_menu = false ;
352+ }
352353 }
353354 }
354355
@@ -541,22 +542,35 @@ impl App {
541542 async fn perform_device_disconnection ( & self , device : & crate :: bz:: device:: Device ) -> Result < ( ) > {
542543 debug ! ( "Disconnecting from device: {}" , device. alias) ;
543544
544- self . pairing_manager . disconnect_device ( device) . await ?;
545-
546- let msg = t ! (
547- "notifications.bt.device_disconnected" ,
548- device_name = device. alias
549- ) ;
550-
551- info ! ( "{msg}" ) ;
552- try_send_notification ! (
553- self . notification_manager,
554- None ,
555- Some ( msg. to_string( ) ) ,
556- Some ( "bluetooth" ) ,
557- None ,
558- None
559- ) ;
545+ match self . pairing_manager . disconnect_device ( device) . await {
546+ Ok ( ( ) ) => {
547+ let msg = t ! (
548+ "notifications.bt.device_disconnected" ,
549+ device_name = device. alias
550+ ) ;
551+ info ! ( "{msg}" ) ;
552+ try_send_notification ! (
553+ self . notification_manager,
554+ None ,
555+ Some ( msg. to_string( ) ) ,
556+ Some ( "bluetooth" ) ,
557+ None ,
558+ None
559+ ) ;
560+ }
561+ Err ( e) => {
562+ let msg = e. to_string ( ) ;
563+ info ! ( "{msg}" ) ;
564+ try_send_notification ! (
565+ self . notification_manager,
566+ None ,
567+ Some ( msg) ,
568+ Some ( "bluetooth" ) ,
569+ None ,
570+ None
571+ ) ;
572+ }
573+ }
560574
561575 Ok ( ( ) )
562576 }
@@ -572,54 +586,80 @@ impl App {
572586 device. alias
573587 ) ;
574588
575- device. set_trusted ( trust) . await ?;
576-
577- let msg = if trust {
578- t ! (
579- "notifications.bt.device_trusted" ,
580- device_name = device. alias
581- )
582- } else {
583- t ! (
584- "notifications.bt.device_untrusted" ,
585- device_name = device. alias
586- )
587- } ;
588-
589- info ! ( "{msg}" ) ;
590- try_send_notification ! (
591- self . notification_manager,
592- None ,
593- Some ( msg. to_string( ) ) ,
594- Some ( "bluetooth" ) ,
595- None ,
596- None
597- ) ;
589+ match device. set_trusted ( trust) . await {
590+ Ok ( ( ) ) => {
591+ let msg = if trust {
592+ t ! (
593+ "notifications.bt.device_trusted" ,
594+ device_name = device. alias
595+ )
596+ } else {
597+ t ! (
598+ "notifications.bt.device_untrusted" ,
599+ device_name = device. alias
600+ )
601+ } ;
602+ info ! ( "{msg}" ) ;
603+ try_send_notification ! (
604+ self . notification_manager,
605+ None ,
606+ Some ( msg. to_string( ) ) ,
607+ Some ( "bluetooth" ) ,
608+ None ,
609+ None
610+ ) ;
611+ }
612+ Err ( e) => {
613+ let msg = e. to_string ( ) ;
614+ info ! ( "{msg}" ) ;
615+ try_send_notification ! (
616+ self . notification_manager,
617+ None ,
618+ Some ( msg) ,
619+ Some ( "bluetooth" ) ,
620+ None ,
621+ None
622+ ) ;
623+ }
624+ }
598625
599626 Ok ( ( ) )
600627 }
601628
602- async fn perform_forget_device ( & self , device : & crate :: bz:: device:: Device ) -> Result < ( ) > {
629+ async fn perform_forget_device ( & self , device : & crate :: bz:: device:: Device ) -> Result < bool > {
603630 info ! ( "Forgetting device: {}" , device. alias) ;
604631
605- self . pairing_manager . forget_device ( device) . await ?;
606-
607- let msg = t ! (
608- "notifications.bt.device_forgotten" ,
609- device_name = device. alias
610- ) ;
611-
612- info ! ( "{msg}" ) ;
613- try_send_notification ! (
614- self . notification_manager,
615- None ,
616- Some ( msg. to_string( ) ) ,
617- Some ( "bluetooth" ) ,
618- None ,
619- None
620- ) ;
621-
622- Ok ( ( ) )
632+ match self . pairing_manager . forget_device ( device) . await {
633+ Ok ( ( ) ) => {
634+ let msg = t ! (
635+ "notifications.bt.device_forgotten" ,
636+ device_name = device. alias
637+ ) ;
638+ info ! ( "{msg}" ) ;
639+ try_send_notification ! (
640+ self . notification_manager,
641+ None ,
642+ Some ( msg. to_string( ) ) ,
643+ Some ( "bluetooth" ) ,
644+ None ,
645+ None
646+ ) ;
647+ Ok ( true )
648+ }
649+ Err ( e) => {
650+ let msg = e. to_string ( ) ;
651+ info ! ( "{msg}" ) ;
652+ try_send_notification ! (
653+ self . notification_manager,
654+ None ,
655+ Some ( msg) ,
656+ Some ( "bluetooth" ) ,
657+ None ,
658+ None
659+ ) ;
660+ Ok ( false )
661+ }
662+ }
623663 }
624664
625665 async fn perform_adapter_disable (
0 commit comments