From e23894c2e6de1661733f164693e9b07a574f8f18 Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Thu, 28 May 2026 12:04:44 +0200 Subject: [PATCH] make usb handle same as discord (#969) --- src/lib.rs | 5 ++--- src/ui/usb.rs | 13 ++++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 39f1f1d1..00efe19c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -243,9 +243,8 @@ pub async fn run(args: Args, arg_count: usize) -> std::io::Result<()> { } } } - if let Some(shutdown_tx) = &shutdown_tx { - ui::usb::close(shutdown_tx, usb_handle).await; - } + + ui::usb::close(shutdown_tx, usb_handle).await; } else if arg_count > 1 { let mut config = ui::config::Config::new(); diff --git a/src/ui/usb.rs b/src/ui/usb.rs index 9546935b..6cf5843a 100644 --- a/src/ui/usb.rs +++ b/src/ui/usb.rs @@ -175,16 +175,19 @@ pub fn init() -> ( } pub async fn close( - shutdown_tx: &tokio::sync::watch::Sender<()>, + shutdown_tx: Option>, usb_handle: Option>, ) { - let _ = shutdown_tx.send(()); if let Some(mut handle) = usb_handle - && tokio::time::timeout(std::time::Duration::from_secs(1), &mut handle) + && let Some(shutdown_tx) = shutdown_tx + { + let _ = shutdown_tx.send(()); + if tokio::time::timeout(std::time::Duration::from_secs(1), &mut handle) .await .is_err() - { - handle.abort(); + { + handle.abort(); + } } }