From 958090436ccc070319f14495873b9ffb31e51120 Mon Sep 17 00:00:00 2001 From: bbb651 Date: Thu, 22 Aug 2024 14:39:34 +0300 Subject: [PATCH] improv(toaster): don't immediatly close without `tokio` --- src/widget/toaster/mod.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/widget/toaster/mod.rs b/src/widget/toaster/mod.rs index 60c9899e..8f1e436c 100644 --- a/src/widget/toaster/mod.rs +++ b/src/widget/toaster/mod.rs @@ -176,13 +176,19 @@ impl Toasts { let id = self.toasts.len(); self.toasts.push_back(toast); - let on_close = self.on_close; - crate::command::future(async move { - #[cfg(feature = "tokio")] - tokio::time::sleep(duration).await; - on_close(id) - }) + #[cfg(feature = "tokio")] + { + let on_close = self.on_close; + crate::command::future(async move { + tokio::time::sleep(duration).await; + on_close(id) + }) + } + #[cfg(not(feature = "tokio"))] + { + Command::none() + } } /// Remove a [`Toast`]