NSClient: fix json parsing

This commit is contained in:
Milos Kozak 2022-05-25 16:12:09 +02:00
parent b0736b5246
commit 5aa1d988b1

View file

@ -66,20 +66,12 @@ fun temporaryTargetFromJson(jsonObject: JSONObject): TemporaryTarget? {
if (duration > 0L) {
// not ending event
if (units == GlucoseUnit.MMOL) {
if (low < Constants.MIN_TT_MMOL) return null
if (low > Constants.MAX_TT_MMOL) return null
if (high < Constants.MIN_TT_MMOL) return null
if (high > Constants.MAX_TT_MMOL) return null
if (low > high) return null
} else {
if (low < Constants.MIN_TT_MGDL) return null
if (low > Constants.MAX_TT_MGDL) return null
if (high < Constants.MIN_TT_MGDL) return null
if (high > Constants.MAX_TT_MGDL) return null
if (low > high) return null
}
}
val tt = TemporaryTarget(
timestamp = timestamp,
duration = durationInMilliseconds ?: T.mins(duration).msecs(),