fix storing carbs

This commit is contained in:
Milos Kozak 2021-11-08 13:36:54 +01:00
parent 7cf4db5fcc
commit 2a2bb4edc6

View file

@ -223,12 +223,14 @@ class CommandQueueImplementation @Inject constructor(
// Assuming carbs in the future and carbs with duration are NOT stores anyway
var carbsRunnable = Runnable { }
val originalCarbs = detailedBolusInfo.carbs
if ((detailedBolusInfo.carbs > 0) &&
(!activePlugin.activePump.pumpDescription.storesCarbInfo ||
detailedBolusInfo.carbsDuration != 0L ||
(detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp) > dateUtil.now())
) {
carbsRunnable = Runnable {
detailedBolusInfo.carbs = originalCarbs
disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction())
.subscribeBy(
onSuccess = { result ->