a bit more readable

This commit is contained in:
AdrianLxM 2021-02-28 14:18:17 +01:00
parent 6dce871ed4
commit 76756fabaa

View file

@ -39,15 +39,12 @@ class DashHistory @Inject constructor(
when { when {
commandType == SET_BOLUS && bolusRecord == null -> commandType == SET_BOLUS && bolusRecord == null ->
Single.error(IllegalArgumentException("bolusRecord missing on SET_BOLUS")) return Single.error(IllegalArgumentException("bolusRecord missing on SET_BOLUS"))
commandType == SET_TEMPORARY_BASAL && tempBasalRecord == null -> commandType == SET_TEMPORARY_BASAL && tempBasalRecord == null ->
Single.error<String>(IllegalArgumentException("tempBasalRecord missing on SET_TEMPORARY_BASAL")) return Single.error(IllegalArgumentException("tempBasalRecord missing on SET_TEMPORARY_BASAL"))
else -> null }
}?.let { return it }
return dao.save(HistoryRecordEntity(
return dao.save(
HistoryRecordEntity(
id = id, id = id,
date = date, date = date,
createdAt = currentTimeMillis(), createdAt = currentTimeMillis(),
@ -56,8 +53,7 @@ class DashHistory @Inject constructor(
bolusRecord = bolusRecord, bolusRecord = bolusRecord,
initialResult = initialResult, initialResult = initialResult,
resolvedResult = resolveResult, resolvedResult = resolveResult,
resolvedAt = resolvedAt, resolvedAt = resolvedAt)
)
).toSingle { id } ).toSingle { id }
} }