소스 검색

Buggfix minAgo scheduling

Jonas Björkert 1 년 전
부모
커밋
b5064b8a54
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 4
      LoopFollow/Task/MinAgoTask.swift

+ 7 - 4
LoopFollow/Task/MinAgoTask.swift

@@ -79,12 +79,15 @@ extension MainViewController {
         // Determine the next run interval based on the current state
         let nextUpdateInterval: TimeInterval
         if shouldDisplaySeconds {
-            nextUpdateInterval = 1.0 // Update every second when showing seconds
-        } else if secondsAgo >= 720 {
-            nextUpdateInterval = 60.0 // Update every minute when showing minutes only
-        } else {
+            // Update every second when showing seconds
+            nextUpdateInterval = 1.0
+        } else if secondsAgo >= 240 && secondsAgo < 720 {
             // Schedule exactly at the transition point to start showing seconds
             nextUpdateInterval = 270.0 - secondsAgo
+        } else {
+            // Schedule exactly at the transition point to next minute
+            let secondsToNextMinute = 60.0 - (secondsAgo.truncatingRemainder(dividingBy: 60.0))
+            nextUpdateInterval = secondsToNextMinute
         }
 
         // Ensure the nextUpdateInterval is not negative or too small