diff --git a/src/sync_logic.rs b/src/sync_logic.rs index 57011b2..c96bb0c 100644 --- a/src/sync_logic.rs +++ b/src/sync_logic.rs @@ -77,6 +77,17 @@ impl LtcState { match frame.status.as_str() { "LOCK" => { self.lock_count += 1; + + // Every 5 seconds, recompute whether HH:MM:SS matches local time + let now_secs = Utc::now().timestamp(); + if now_secs - self.last_match_check >= 5 { + self.last_match_status = if frame.matches_system_time() { + "IN SYNC".into() + } else { + "OUT OF SYNC".into() + }; + self.last_match_check = now_secs; + } } "FREE" => { self.free_count += 1; @@ -86,17 +97,6 @@ impl LtcState { _ => {} } - // Every 5 seconds, recompute whether HH:MM:SS matches local time - let now_secs = Utc::now().timestamp(); - if now_secs - self.last_match_check >= 5 { - self.last_match_status = if frame.matches_system_time() { - "IN SYNC".into() - } else { - "OUT OF SYNC".into() - }; - self.last_match_check = now_secs; - } - self.latest = Some(frame); }