Skip to content
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

Utilize max bolus limit in Bolus module #100

Merged
merged 4 commits into from
May 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ Enact a temp Basal or a temp target */
"Bolus failed" = "Bolus failed";

/* "Max Bolus Exceeded label" */
"Max Bolus exceeded!" = "Max Bolus exceeded!";
"Max Bolus exceeded!" = "¡Bolo máximo superado!";

/* */
"Bolus failed or inaccurate. Check pump history before repeating." = "Bolus failed or inaccurate. Check pump history before repeating.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
/* Continue after added carbs without bolus */
"Continue without bolus" = "Fortsätt utan bolus";

/* Alert when adding large amount without bolusing */
"\nAmount is more than your Max Bolus setting! \nAre you sure you want to add " = "\nDetta är mer insulin än din maxdos-inställning!\nÄr du säker på att du vill lägga till ";
/* Alert when adding large amount without bolusing. Don't remove the " " */
"\nAmount is more than your Max Bolus setting! \nAre you sure you want to add " = "\nDetta är mer insulin än din maxdos-inställning! \nÄr du säker på att du vill lägga till ";

/* Header */
"Enact Bolus" = "Ge bolus";
Expand Down
4 changes: 3 additions & 1 deletion FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extension Bolus {
@Published var expectedDelta: Decimal = 0
@Published var minPredBG: Decimal = 0
@Published var units: GlucoseUnits = .mmolL
@Published var maxBolus: Decimal = 0

var waitForSuggestionInitial: Bool = false

Expand All @@ -34,6 +35,7 @@ extension Bolus {
units = settingsManager.settings.units
percentage = settingsManager.settings.insulinReqPercentage
threshold = provider.suggestion?.threshold ?? 0
maxBolus = provider.pumpSettings().maxBolus

if waitForSuggestionInitial {
apsManager.determineBasal()
Expand All @@ -55,7 +57,7 @@ extension Bolus {
return
}

let maxAmount = Double(min(amount, provider.pumpSettings().maxBolus))
let maxAmount = Double(min(amount, maxBolus))

unlockmanager.unlock()
.sink { _ in } receiveValue: { [weak self] _ in
Expand Down
13 changes: 11 additions & 2 deletions FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,17 @@ extension Bolus {
header: { Text("Bolus") }
Section {
Button { state.add() }
label: { Text("Enact bolus") }
.disabled(state.amount <= 0)
label: {
Text(
state.amount < state.maxBolus ? NSLocalizedString("Enact bolus", comment: "") :
NSLocalizedString("Max Bolus exceeded!", comment: "")
+ " (>"
+ formatter.string(from: state.maxBolus as NSNumber)!
+ ")"
) }
.disabled(
state.amount <= 0 || state.amount > state.maxBolus
)
}
if waitForSuggestion {
Section {
Expand Down