From 18b71c6fa6a259a6e6479992e039bceec3c5c774 Mon Sep 17 00:00:00 2001 From: John Rogers Date: Thu, 10 Jul 2025 14:28:17 +0100 Subject: [PATCH] fix: Prevent time sync check on FREE frames Co-authored-by: aider (gemini/gemini-2.5-pro-preview-05-06) --- src/sync_logic.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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); }