diff --git a/src/event.rs b/src/event.rs index a2f945e..fc10fa2 100644 --- a/src/event.rs +++ b/src/event.rs @@ -13,6 +13,7 @@ pub enum Event { Mouse(MouseEvent), Resize(u16, u16), Notification(Notification), + NewPairedDevice, } #[allow(dead_code)] diff --git a/src/handler.rs b/src/handler.rs index cb85d97..b81f43c 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -99,6 +99,40 @@ async fn pair(app: &mut App, sender: UnboundedSender) { NotificationLevel::Info, sender.clone(), ); + + let _ = sender.send(Event::NewPairedDevice); + match device.set_trusted(true).await { + Ok(_) => { + let _ = Notification::send( + "Device trusted".to_string(), + NotificationLevel::Info, + sender.clone(), + ); + } + Err(e) => { + let _ = Notification::send( + e.to_string(), + NotificationLevel::Error, + sender.clone(), + ); + } + }; + match device.connect().await { + Ok(_) => { + let _ = Notification::send( + "Device connected".to_string(), + NotificationLevel::Info, + sender.clone(), + ); + } + Err(e) => { + let _ = Notification::send( + e.to_string(), + NotificationLevel::Error, + sender.clone(), + ); + } + }; } Err(e) => { let _ = Notification::send( diff --git a/src/main.rs b/src/main.rs index 65844d0..3740862 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,9 @@ async fn main() -> AppResult<()> { Event::Notification(notification) => { app.notifications.push(notification); } + Event::NewPairedDevice => { + app.focused_block = bluetui::app::FocusedBlock::PairedDevices; + } _ => {} } }