Browse Source

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

Deniz Cengiz 1 year ago
parent
commit
3a49cd9f2e

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

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