From bdf4df4bc316a5ed1956538b19e677a7913212da Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 3 Feb 2022 21:33:56 +0100 Subject: [PATCH] Fix register carbs only treatment dialog --- .../nightscout/androidaps/dialogs/TreatmentDialog.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt index 56dbe3ccb7..29e6290571 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -179,9 +179,17 @@ class TreatmentDialog : DialogFragmentWithDate() { } } }) - } else + } else { uel.log(action, Sources.TreatmentDialog, - ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbs != 0 }) + ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 }) + if (detailedBolusInfo.carbs > 0) { + disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction()) + .subscribe( + { result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted carbs $it") } }, + { aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) } + ) + } + } } }) }