General Dev

This commit is contained in:
Breadway 2026-05-18 23:01:52 +08:00
parent 255be18ca2
commit e233750b24
5 changed files with 61 additions and 22 deletions

View file

@ -10,7 +10,11 @@ pub fn spawn_ticker(sender: ComponentSender<App>) {
relm4::spawn(async move {
loop {
sender.input(AppInput::ClockTick);
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
// Sleep until the top of the next minute — display is HH:MM only.
let secs = gtk4::glib::DateTime::now_local()
.map_or(0, |dt| dt.second());
let wait = (60 - secs.rem_euclid(60)) as u64;
tokio::time::sleep(std::time::Duration::from_secs(wait.max(1))).await;
}
});
}