From 11eb4cefc298e9a4609071387d6b25a9d51a0af9 Mon Sep 17 00:00:00 2001 From: 13r0ck Date: Thu, 22 Dec 2022 11:10:47 -0700 Subject: [PATCH] Time: Set minimum wait for subscription to 1ms The Clock was freezing with ``` ERRO thread 'main' panicked at '`period` must be non-zero.', /home/system76/ca/cosmic-applets/applets/cosmic-applet-time/vendor/iced_futures/src/backend/native/tokio.rs:62:21 ``` --- cosmic-applet-time/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cosmic-applet-time/src/main.rs b/cosmic-applet-time/src/main.rs index 9ac79330..e027fdc8 100644 --- a/cosmic-applet-time/src/main.rs +++ b/cosmic-applet-time/src/main.rs @@ -100,7 +100,7 @@ impl Application for Time { .expect("Setting seconds to 0 should always be possible") .with_nanosecond(0) .expect("Setting nanoseconds to 0 should always be possible."); - let wait = (next - now).num_milliseconds(); + let wait = 1.max((next - now).num_milliseconds()); time::every(Duration::from_millis( wait.try_into().unwrap_or(FALLBACK_DELAY), ))