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

Refine bolus-in-progress logic to allow meal and external insulin entry despite bolus in progress; only prohibit pump bolus #162

Deniz Cengiz 1 год назад
Родитель
Сommit
45c8d79e5e
1 измененных файлов с 13 добавлено и 7 удалено
  1. 13 7
      FreeAPS/Sources/Modules/Treatments/View/TreatmentsRootView.swift

+ 13 - 7
FreeAPS/Sources/Modules/Treatments/View/TreatmentsRootView.swift

@@ -376,7 +376,9 @@ extension Treatments {
                 state.invokeTreatmentsTask()
             } label: {
                 HStack {
-                    if state.isBolusInProgress {
+                    if state.isBolusInProgress && state
+                        .amount > 0 && !state.externalInsulin && (state.carbs == 0 || state.fat == 0 || state.protein == 0)
+                    {
                         ProgressView()
                     }
                     taskButtonLabel
@@ -393,12 +395,8 @@ extension Treatments {
         }
 
         private var taskButtonLabel: some View {
-            if state.isBolusInProgress {
-                return Text("Bolus In Progress...")
-            }
-
             if pumpBolusLimitExceeded {
-                return Text("Max Bolus of \(state.maxBolus.description) U Exceeded")
+                return Text("Max Bolus of \(state.maxBolus.description) U E== 0xceeded")
             } else if externalBolusLimitExceeded {
                 return Text("Max External Bolus of \(state.maxExternal.description) U Exceeded")
             } else if carbLimitExceeded {
@@ -414,6 +412,10 @@ extension Treatments {
             let hasFatOrProtein = state.fat > 0 || state.protein > 0
             let bolusString = state.externalInsulin ? "External Insulin" : "Enact Bolus"
 
+            if state.isBolusInProgress && hasInsulin && !state.externalInsulin && (!hasCarbs || !hasFatOrProtein) {
+                return Text("Bolus In Progress...")
+            }
+
             switch (hasInsulin, hasCarbs, hasFatOrProtein) {
             case (true, true, true):
                 return Text("Log Meal and \(bolusString)")
@@ -459,7 +461,11 @@ extension Treatments {
         }
 
         private var disableTaskButton: Bool {
-            state.isBolusInProgress || state.addButtonPressed || limitExceeded
+            (
+                state.isBolusInProgress && state
+                    .amount > 0 && !state.externalInsulin && (state.carbs == 0 || state.fat == 0 || state.protein == 0)
+            ) || state
+                .addButtonPressed || limitExceeded
         }
     }