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

Update remaining BolusProgressState.clear call sites

Two callers outside the bolusTrigger sink still used the old clear()
signature: cancelBolus (direct actor call) and doseProgressReporter-
DidUpdate (calls clearBolusReporter on bolus completion). Update them
to pass observer: self, and wrap the latter in a Task since the
DoseProgressObserver protocol method is sync and clearBolusReporter is
now async.
Marvin Polscheit 1 день назад
Родитель
Сommit
591b3ef295
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      Trio/Sources/APS/APSManager.swift

+ 7 - 2
Trio/Sources/APS/APSManager.swift

@@ -646,7 +646,7 @@ final class BaseAPSManager: APSManager, Injectable {
                 )
             )
         }
-        await bolusProgressState.clear()
+        _ = await bolusProgressState.clear(observer: self)
         bolusProgress.send(nil)
     }
 
@@ -1358,7 +1358,12 @@ extension BaseAPSManager: DoseProgressObserver {
     func doseProgressReporterDidUpdate(_ doseProgressReporter: DoseProgressReporter) {
         bolusProgress.send(Decimal(doseProgressReporter.progress.percentComplete))
         if doseProgressReporter.progress.isComplete {
-            clearBolusReporter()
+            // Protocol method is sync — wrap the now-async clear in a Task.
+            // The 500 ms delayed send(nil) is gated by the generation token in
+            // BolusProgressState, so a new bolus arriving in the meantime won't be clobbered.
+            Task { [weak self] in
+                await self?.clearBolusReporter()
+            }
         }
     }
 }