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 // Assuming carbs in the future and carbs with duration are NOT stores anyway
var carbsRunnable = Runnable { } var carbsRunnable = Runnable { }
val originalCarbs = detailedBolusInfo.carbs
if ((detailedBolusInfo.carbs > 0) && if ((detailedBolusInfo.carbs > 0) &&
(!activePlugin.activePump.pumpDescription.storesCarbInfo || (!activePlugin.activePump.pumpDescription.storesCarbInfo ||
detailedBolusInfo.carbsDuration != 0L || detailedBolusInfo.carbsDuration != 0L ||
(detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp) > dateUtil.now()) (detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp) > dateUtil.now())
) { ) {
carbsRunnable = Runnable { carbsRunnable = Runnable {
detailedBolusInfo.carbs = originalCarbs
disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction()) disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction())
.subscribeBy( .subscribeBy(
onSuccess = { result -> onSuccess = { result ->