Fix panic on pausing dead tasks

This commit is contained in:
Jonathan Kelley committed 2024-02-02 14:33:02 -08:00
1 parent ee19df55c7
commit 3295935de7
2 files changed
+33 -20

No files matched your search

+14 -9
View File
@@ -12,16 +12,21 @@ fn app() -> Element {
use_future(move || async move {
let mut focused = 0;
if running() {
loop {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
if let Some(element) = elements.with(|f| f.get(focused).cloned()) {
_ = element.set_focus(true).await;
} else {
focused = 0;
}
focused += 1;
loop {
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
if !running() {
continue;
}
if let Some(element) = elements.with(|f| f.get(focused).cloned()) {
_ = element.set_focus(true).await;
} else {
focused = 0;
}
focused += 1;
}
});