improv(toaster): don't immediatly close without tokio

This commit is contained in:
bbb651 2024-08-22 14:39:34 +03:00
parent ba7001ee59
commit 958090436c

View file

@ -176,13 +176,19 @@ impl<Message: Clone + Send + 'static> Toasts<Message> {
let id = self.toasts.len(); let id = self.toasts.len();
self.toasts.push_back(toast); self.toasts.push_back(toast);
let on_close = self.on_close;
crate::command::future(async move { #[cfg(feature = "tokio")]
#[cfg(feature = "tokio")] {
tokio::time::sleep(duration).await; let on_close = self.on_close;
on_close(id) crate::command::future(async move {
}) tokio::time::sleep(duration).await;
on_close(id)
})
}
#[cfg(not(feature = "tokio"))]
{
Command::none()
}
} }
/// Remove a [`Toast`] /// Remove a [`Toast`]