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

fix: basalProfileDidChange got call too soon

bastiaanv 5 месяцев назад
Родитель
Сommit
35142bc382
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      Trio/Sources/Modules/BasalProfileEditor/BasalProfileEditorStateModel.swift

+ 6 - 6
Trio/Sources/Modules/BasalProfileEditor/BasalProfileEditorStateModel.swift

@@ -113,6 +113,12 @@ extension BasalProfileEditor {
                         // Successfully saved and synced
                         // Successfully saved and synced
                         self.initialItems = self.items.map { Item(rateIndex: $0.rateIndex, timeIndex: $0.timeIndex) }
                         self.initialItems = self.items.map { Item(rateIndex: $0.rateIndex, timeIndex: $0.timeIndex) }
 
 
+                        DispatchQueue.main.async {
+                            self.broadcaster.notify(BasalProfileObserver.self, on: .main) {
+                                $0.basalProfileDidChange(profile)
+                            }
+                        }
+
                         Task.detached(priority: .low) {
                         Task.detached(priority: .low) {
                             do {
                             do {
                                 debug(.nightscout, "Attempting to upload basal rates to Nightscout")
                                 debug(.nightscout, "Attempting to upload basal rates to Nightscout")
@@ -130,12 +136,6 @@ extension BasalProfileEditor {
                     print("We were successful")
                     print("We were successful")
                 }
                 }
                 .store(in: &lifetime)
                 .store(in: &lifetime)
-
-            DispatchQueue.main.async {
-                self.broadcaster.notify(BasalProfileObserver.self, on: .main) {
-                    $0.basalProfileDidChange(profile)
-                }
-            }
         }
         }
 
 
         @MainActor func validate() {
         @MainActor func validate() {