diff --git a/applets/cosmic-applet-network/src/task.rs b/applets/cosmic-applet-network/src/task.rs index 61d79cf8..37078fbb 100644 --- a/applets/cosmic-applet-network/src/task.rs +++ b/applets/cosmic-applet-network/src/task.rs @@ -14,11 +14,14 @@ pub fn spawn_local + 'static>(future: F) { gtk4::glib::MainContext::default().spawn_local(future); } -pub async fn wait_for_local + 'static>(future: F) { - let (tx, rx) = oneshot::channel::<()>(); +pub async fn wait_for_local(future: F) -> Option +where + O: Send + 'static, + F: Future + Send + 'static, +{ + let (tx, rx) = oneshot::channel::(); gtk4::glib::MainContext::default().spawn_local(async move { - future.await; - let _ = tx.send(()); + std::mem::drop(tx.send(future.await)); }); - std::mem::drop(rx.await); + rx.await.ok() }