Skip to content

Commit 6a26e1e

Browse files
gmglbn-0Copilot
andauthored
Update src/main.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 948ad31 commit 6a26e1e

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

src/main.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -632,18 +632,15 @@ mod home_assistant_handler {
632632
});
633633

634634
let weak = app.as_weak();
635-
let timer = slint::Timer::default();
636-
timer.start(
637-
slint::TimerMode::Repeated,
638-
std::time::Duration::from_millis(200),
639-
move || {
640-
if rx.try_recv().is_ok()
641-
&& let Some(window) = weak.upgrade()
642-
{
643-
window.invoke_close_hass_remote();
644-
}
645-
},
646-
);
647-
std::mem::forget(timer);
635+
thread::spawn(move || {
636+
while rx.recv().is_ok() {
637+
let weak = weak.clone();
638+
let _ = slint::invoke_from_event_loop(move || {
639+
if let Some(window) = weak.upgrade() {
640+
window.invoke_close_hass_remote();
641+
}
642+
});
643+
}
644+
});
648645
}
649646
}

0 commit comments

Comments
 (0)