NSC: accept Temporary target cancel from AAPSClient

This commit is contained in:
Milos Kozak 2023-01-21 13:30:51 +01:00
parent 0569d2ba0a
commit 2b7c082979
2 changed files with 3 additions and 3 deletions

View file

@ -7,7 +7,7 @@ import kotlin.math.abs
/** /**
* Sync the TemporaryTarget from NS * Sync the TemporaryTarget from NS
*/ */
class SyncNsTemporaryTargetTransaction(private val temporaryTargets: List<TemporaryTarget>, private val nsClientMode: Boolean) : class SyncNsTemporaryTargetTransaction(private val temporaryTargets: List<TemporaryTarget>) :
Transaction<SyncNsTemporaryTargetTransaction.TransactionResult>() { Transaction<SyncNsTemporaryTargetTransaction.TransactionResult>() {
override fun run(): TransactionResult { override fun run(): TransactionResult {
@ -28,7 +28,7 @@ class SyncNsTemporaryTargetTransaction(private val temporaryTargets: List<Tempor
database.temporaryTargetDao.updateExistingEntry(current) database.temporaryTargetDao.updateExistingEntry(current)
result.invalidated.add(current) result.invalidated.add(current)
} }
if (current.duration != temporaryTarget.duration && nsClientMode) { if (current.duration != temporaryTarget.duration) {
current.duration = temporaryTarget.duration current.duration = temporaryTarget.duration
database.temporaryTargetDao.updateExistingEntry(current) database.temporaryTargetDao.updateExistingEntry(current)
result.updatedDuration.add(current) result.updatedDuration.add(current)

View file

@ -325,7 +325,7 @@ class StoreDataForDbImpl @Inject constructor(
SystemClock.sleep(pause) SystemClock.sleep(pause)
if (temporaryTargets.isNotEmpty()) if (temporaryTargets.isNotEmpty())
repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTargets, config.NSCLIENT)) repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTargets))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
} }