File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,20 @@ public class Services.TimeMonitor : Object {
3030 }
3131
3232 private DateTime last_registered_date;
33+ private uint timeout_id = 0 ;
3334
3435 public void init_timeout () {
3536 last_registered_date = new DateTime .now_local ();
36- uint interval = calculate_seconds_until_midnight ();
37+ schedule_next_check ();
38+ }
3739
38- Timeout . add_seconds (interval, on_timeout);
40+ private void schedule_next_check () {
41+ if (timeout_id != 0 ) {
42+ Source . remove (timeout_id);
43+ }
44+
45+ uint interval = calculate_seconds_until_midnight ();
46+ timeout_id = Timeout . add_seconds (interval, on_timeout);
3947 }
4048
4149 private bool on_timeout () {
@@ -49,14 +57,9 @@ public class Services.TimeMonitor : Object {
4957 Services . Notification . get_default (). regresh ();
5058
5159 last_registered_date = now;
52- uint interval = calculate_seconds_until_midnight ();
53-
54- Timeout . add_seconds (interval, on_timeout);
55- } else {
56- uint interval = calculate_seconds_until_midnight ();
57- Timeout . add_seconds (interval, on_timeout);
5860 }
5961
62+ schedule_next_check ();
6063 return false ;
6164 }
6265
You can’t perform that action at this time.
0 commit comments