瀏覽代碼

Reset basalProfileItems when pump model changes to avoid index out of bound error

Deniz Cengiz 1 年之前
父節點
當前提交
3a49cd9f2e
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      Trio/Sources/Modules/Onboarding/View/OnboardingSteps/UnitSelectionStepView.swift

+ 4 - 0
Trio/Sources/Modules/Onboarding/View/OnboardingSteps/UnitSelectionStepView.swift

@@ -30,6 +30,10 @@ struct UnitSelectionStepView: View {
                         Text(pumpModel.displayName).tag(pumpModel)
                         Text(pumpModel.displayName).tag(pumpModel)
                     }
                     }
                 }
                 }
+                .onChange(of: state.pumpOptionForOnboardingUnits, { _, _ in
+                    // Reset basal profile and related values when pump model changes
+                    state.basalProfileItems = []
+                })
             }
             }
             .padding()
             .padding()
             .background(Color.chart.opacity(0.65))
             .background(Color.chart.opacity(0.65))