@@ -718,56 +718,56 @@ pub async fn handle_key_events(
718718
719719 FocusedBlock :: NewDevices => {
720720 // Pair new device
721- if KeyCode :: Char ( config. new_device . pair ) == key_event. code {
722- if let Some ( selected_controller) = app. controller_state . selected ( ) {
723- let controller = & app. controllers [ selected_controller] ;
724- if let Some ( index) = app. new_devices_state . selected ( ) {
725- let addr = controller. new_devices [ index] . addr ;
726- match controller. adapter . device ( addr) {
727- Ok ( device) => match device. alias ( ) . await {
728- Ok ( device_name) => {
729- let _ = Notification :: send (
730- format ! (
731- "Start pairing with the device\n `{device_name}`" ,
732- ) ,
733- NotificationLevel :: Info ,
734- sender. clone ( ) ,
735- ) ;
721+ if KeyCode :: Char ( config. new_device . pair ) == key_event. code
722+ && let Some ( selected_controller) = app. controller_state . selected ( )
723+ {
724+ let controller = & app. controllers [ selected_controller] ;
725+ if let Some ( index) = app. new_devices_state . selected ( ) {
726+ let addr = controller. new_devices [ index] . addr ;
727+ match controller. adapter . device ( addr) {
728+ Ok ( device) => match device. alias ( ) . await {
729+ Ok ( device_name) => {
730+ let _ = Notification :: send (
731+ format ! (
732+ "Start pairing with the device\n `{device_name}`" ,
733+ ) ,
734+ NotificationLevel :: Info ,
735+ sender. clone ( ) ,
736+ ) ;
736737
737- tokio:: spawn ( async move {
738- match device. pair ( ) . await {
739- Ok ( _) => {
740- let _ = Notification :: send (
741- "Device paired" . to_string ( ) ,
742- NotificationLevel :: Info ,
743- sender. clone ( ) ,
744- ) ;
745- }
746- Err ( e) => {
747- let _ = Notification :: send (
748- e. to_string ( ) ,
749- NotificationLevel :: Error ,
750- sender. clone ( ) ,
751- ) ;
752- }
738+ tokio:: spawn ( async move {
739+ match device. pair ( ) . await {
740+ Ok ( _) => {
741+ let _ = Notification :: send (
742+ "Device paired" . to_string ( ) ,
743+ NotificationLevel :: Info ,
744+ sender. clone ( ) ,
745+ ) ;
753746 }
754- } ) ;
755- }
756- Err ( e ) => {
757- let _ = Notification :: send (
758- e . to_string ( ) ,
759- NotificationLevel :: Error ,
760- sender . clone ( ) ,
761- ) ;
762- }
763- } ,
747+ Err ( e ) => {
748+ let _ = Notification :: send (
749+ e . to_string ( ) ,
750+ NotificationLevel :: Error ,
751+ sender . clone ( ) ,
752+ ) ;
753+ }
754+ }
755+ } ) ;
756+ }
764757 Err ( e) => {
765758 let _ = Notification :: send (
766759 e. to_string ( ) ,
767760 NotificationLevel :: Error ,
768761 sender. clone ( ) ,
769762 ) ;
770763 }
764+ } ,
765+ Err ( e) => {
766+ let _ = Notification :: send (
767+ e. to_string ( ) ,
768+ NotificationLevel :: Error ,
769+ sender. clone ( ) ,
770+ ) ;
771771 }
772772 }
773773 }
0 commit comments