Просмотр исходного кода

Add missing cycleDuration fetch to ProcessDexBGData from storage.shared.backgroundRefreshType

Daniel Snällfot 1 год назад
Родитель
Сommit
aaaabc9c59
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      LoopFollow/Controllers/Nightscout/BGData.swift

+ 5 - 2
LoopFollow/Controllers/Nightscout/BGData.swift

@@ -135,8 +135,11 @@ extension MainViewController {
         // secondsAgo is how old the newest reading is
         let secondsAgo = now - sensorTimestamp
 
-        // Compute the current sensor schedule offset.
-        let currentOffset = sensorScheduleOffset(for: sensorTimestamp)
+        // Determine the cycle duration based on device type.
+        let cycleDuration: TimeInterval = (Storage.shared.backgroundRefreshType.value == .rileyLink) ? 60 : 300
+
+        // Compute the current sensor schedule offset using the appropriate cycle.
+        let currentOffset = sensorScheduleOffset(for: sensorTimestamp, cycle: cycleDuration)
 
         if Storage.shared.sensorScheduleOffset.value != currentOffset {
             Storage.shared.sensorScheduleOffset.value = currentOffset