preserve invalidated status for cgm data

This commit is contained in:
Milos Kozak 2021-10-25 15:50:27 +02:00
parent 3d94f3f840
commit 4c4122c6a6

View file

@ -27,11 +27,14 @@ class CgmSourceTransaction(
noise = it.noise, noise = it.noise,
trendArrow = it.trendArrow, trendArrow = it.trendArrow,
sourceSensor = it.sourceSensor sourceSensor = it.sourceSensor
) ).also { gv ->
glucoseValue.interfaceIDs.nightscoutId = it.nightscoutId gv.interfaceIDs.nightscoutId = it.nightscoutId
}
// if nsId is not provided in new record, copy from current if exists // if nsId is not provided in new record, copy from current if exists
if (glucoseValue.interfaceIDs.nightscoutId == null) if (glucoseValue.interfaceIDs.nightscoutId == null)
current?.let { existing -> glucoseValue.interfaceIDs.nightscoutId = existing.interfaceIDs.nightscoutId } current?.let { existing -> glucoseValue.interfaceIDs.nightscoutId = existing.interfaceIDs.nightscoutId }
// preserve invalidated status (user may delete record in UI)
current?.let { existing -> glucoseValue.isValid = existing.isValid }
when { when {
// new record, create new // new record, create new
current == null -> { current == null -> {