Merge pull request #758 from samspycher/fix/db-access-expectedPumpState

Fix: prevent DB access on main thread for `expectedPumpState()`
This commit is contained in:
Milos Kozak 2021-10-18 23:55:45 +02:00 committed by GitHub
commit 68f674fd92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,7 +77,7 @@ class PumpSyncImplementation @Inject constructor(
}
override fun expectedPumpState(): PumpSync.PumpState {
val bolus = repository.getLastBolusRecord()
val bolus = repository.getLastBolusRecordWrapped().blockingGet();
val temporaryBasal = repository.getTemporaryBasalActiveAt(dateUtil.now()).blockingGet()
val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil.now()).blockingGet()
@ -104,12 +104,14 @@ class PumpSyncImplementation @Inject constructor(
)
else null,
bolus =
bolus?.let {
PumpSync.PumpState.Bolus(
timestamp = bolus.timestamp,
amount = bolus.amount
)
},
if (bolus is ValueWrapper.Existing)
bolus.value.let {
PumpSync.PumpState.Bolus(
timestamp = bolus.value.timestamp,
amount = bolus.value.amount
)
}
else null,
profile = profileFunction.getProfile()
)
}