Skip to content

LOOP-5351 Preset guardrail fixes. #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Loop/Managers/SettingsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ extension SettingsManager {
case .legacyWorkout:
return legacyWorkoutPresetGuardrail
default:
return customPresetGuardRail
return Guardrail.temporaryPresetCorrectionRange
}
}

Expand Down Expand Up @@ -373,10 +373,6 @@ extension SettingsManager {
}
}

public var customPresetGuardRail: Guardrail<LoopQuantity> {
return Guardrail.temporaryPresetCorrectionRange(suspendThreshold: settings.suspendThreshold)
}

func savePreset(_ preset: SelectablePreset) {
switch(preset) {
case .preMeal(let range):
Expand Down
2 changes: 1 addition & 1 deletion Loop/Views/Presets/CreatePresetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct CreatePresetView: View {
NewPresetRangeEdit(
preset: $preset,
path: $path,
guardrail: Guardrail.temporaryPresetCorrectionRange(suspendThreshold: suspendThreshold),
guardrail: Guardrail.temporaryPresetCorrectionRange,
scheduledRange: scheduledRange,
onCancel: { dismiss() }
)
Expand Down
4 changes: 3 additions & 1 deletion Loop/Views/Presets/PresetRangeEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct PresetRangeEditor: View {
@Environment(\.dismiss) private var dismiss
@Environment(\.guidanceColors) private var guidanceColors
@EnvironmentObject private var displayGlucosePreference: DisplayGlucosePreference
@Environment(\.settingsManager) private var settingsManager


@State private var presentInfoView: Bool = false
@Binding var range: ClosedRange<LoopQuantity>?
Expand Down Expand Up @@ -125,7 +127,7 @@ struct PresetRangeEditor: View {
get: { displayedRange },
set: { range = $0 }),
unit: displayGlucosePreference.unit,
minValue: nil,
minValue: settingsManager.settings.suspendThreshold?.quantity,
guardrail: guardrail)
.padding(.vertical, -20)
}
Expand Down
6 changes: 5 additions & 1 deletion Loop/Views/Presets/ReviewNewPresetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ struct ReviewNewPresetView: View {
sensitivitySection

CardSection {
CorrectionRangePreview(range: preset.correctionRange, guardrail: Guardrail.correctionRange, scheduledRange: scheduledRange)
CorrectionRangePreview(
range: preset.correctionRange,
guardrail: Guardrail.temporaryPresetCorrectionRange,
scheduledRange: scheduledRange
)
}

// Name Field
Expand Down