From e08af1e7e45eeffeff347bda81139b42a0e7237b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 26 Jun 2021 22:15:02 +0200 Subject: [PATCH] fix NS sync issue --- .../UpdateNsIdBolusCalculatorResultTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdBolusTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdCarbsTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdDeviceStatusTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdExtendedBolusTransaction.kt | 6 ++++-- .../database/transactions/UpdateNsIdFoodTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdGlucoseValueTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdOfflineEventTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdProfileSwitchTransaction.kt | 6 ++++-- .../UpdateNsIdTemporaryBasalTransaction.kt | 10 ++++++---- .../UpdateNsIdTemporaryTargetTransaction.kt | 6 ++++-- .../transactions/UpdateNsIdTherapyEventTransaction.kt | 6 ++++-- 12 files changed, 50 insertions(+), 26 deletions(-) diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusCalculatorResultTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusCalculatorResultTransaction.kt index da50ce0a55..b824e1b4f4 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusCalculatorResultTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusCalculatorResultTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdBolusCalculatorResultTransaction(val bolusCalculatorResult: Bolu override fun run() { val current = database.bolusCalculatorResultDao.findById(bolusCalculatorResult.id) - if (current != null && current.interfaceIDs.nightscoutId != bolusCalculatorResult.interfaceIDs.nightscoutId) - database.bolusCalculatorResultDao.updateExistingEntry(bolusCalculatorResult) + if (current != null && current.interfaceIDs.nightscoutId != bolusCalculatorResult.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = bolusCalculatorResult.interfaceIDs.nightscoutId + database.bolusCalculatorResultDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusTransaction.kt index a6e0a574ff..2504545419 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdBolusTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdBolusTransaction(val bolus: Bolus) : Transaction() { override fun run() { val current = database.bolusDao.findById(bolus.id) - if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) - database.bolusDao.updateExistingEntry(bolus) + if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = bolus.interfaceIDs.nightscoutId + database.bolusDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdCarbsTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdCarbsTransaction.kt index 2cba4540f9..9595fd3a17 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdCarbsTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdCarbsTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdCarbsTransaction(val carbs: Carbs) : Transaction() { override fun run() { val current = database.carbsDao.findById(carbs.id) - if (current != null && current.interfaceIDs.nightscoutId != carbs.interfaceIDs.nightscoutId) - database.carbsDao.updateExistingEntry(carbs) + if (current != null && current.interfaceIDs.nightscoutId != carbs.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = carbs.interfaceIDs.nightscoutId + database.carbsDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdDeviceStatusTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdDeviceStatusTransaction.kt index 766f672877..159992ba5f 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdDeviceStatusTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdDeviceStatusTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdDeviceStatusTransaction(val deviceStatus: DeviceStatus) : Transa override fun run() { val current = database.deviceStatusDao.findById(deviceStatus.id) - if (current != null && current.interfaceIDs.nightscoutId != deviceStatus.interfaceIDs.nightscoutId) - database.deviceStatusDao.update(deviceStatus) + if (current != null && current.interfaceIDs.nightscoutId != deviceStatus.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = deviceStatus.interfaceIDs.nightscoutId + database.deviceStatusDao.update(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdExtendedBolusTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdExtendedBolusTransaction.kt index cfa12027b1..cc174ad734 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdExtendedBolusTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdExtendedBolusTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdExtendedBolusTransaction(val bolus: ExtendedBolus) : Transaction override fun run() { val current = database.extendedBolusDao.findById(bolus.id) - if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) - database.extendedBolusDao.updateExistingEntry(bolus) + if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = bolus.interfaceIDs.nightscoutId + database.extendedBolusDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdFoodTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdFoodTransaction.kt index e03e38e343..78179c8cb8 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdFoodTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdFoodTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdFoodTransaction(val food: Food) : Transaction() { override fun run() { val current = database.foodDao.findById(food.id) - if (current != null && current.interfaceIDs.nightscoutId != food.interfaceIDs.nightscoutId) - database.foodDao.updateExistingEntry(food) + if (current != null && current.interfaceIDs.nightscoutId != food.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = food.interfaceIDs.nightscoutId + database.foodDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdGlucoseValueTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdGlucoseValueTransaction.kt index 954aadd39b..3b43b92943 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdGlucoseValueTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdGlucoseValueTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdGlucoseValueTransaction(val glucoseValue: GlucoseValue) : Transa override fun run() { val current = database.glucoseValueDao.findById(glucoseValue.id) - if (current != null && current.interfaceIDs.nightscoutId != glucoseValue.interfaceIDs.nightscoutId) - database.glucoseValueDao.updateExistingEntry(glucoseValue) + if (current != null && current.interfaceIDs.nightscoutId != glucoseValue.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = glucoseValue.interfaceIDs.nightscoutId + database.glucoseValueDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdOfflineEventTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdOfflineEventTransaction.kt index ebb19ce486..3da1b26ce7 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdOfflineEventTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdOfflineEventTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdOfflineEventTransaction(val offlineEvent: OfflineEvent) : Transa override fun run() { val current = database.offlineEventDao.findById(offlineEvent.id) - if (current != null && current.interfaceIDs.nightscoutId != offlineEvent.interfaceIDs.nightscoutId) - database.offlineEventDao.updateExistingEntry(offlineEvent) + if (current != null && current.interfaceIDs.nightscoutId != offlineEvent.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = offlineEvent.interfaceIDs.nightscoutId + database.offlineEventDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdProfileSwitchTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdProfileSwitchTransaction.kt index 63a589db51..368a66dc3f 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdProfileSwitchTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdProfileSwitchTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdProfileSwitchTransaction(val profileSwitch: ProfileSwitch) : Tra override fun run() { val current = database.profileSwitchDao.findById(profileSwitch.id) - if (current != null && current.interfaceIDs.nightscoutId != profileSwitch.interfaceIDs.nightscoutId) - database.profileSwitchDao.updateExistingEntry(profileSwitch) + if (current != null && current.interfaceIDs.nightscoutId != profileSwitch.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = profileSwitch.interfaceIDs.nightscoutId + database.profileSwitchDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryBasalTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryBasalTransaction.kt index be9a3c3efa..571f3da027 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryBasalTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryBasalTransaction.kt @@ -2,11 +2,13 @@ package info.nightscout.androidaps.database.transactions import info.nightscout.androidaps.database.entities.TemporaryBasal -class UpdateNsIdTemporaryBasalTransaction(val bolus: TemporaryBasal) : Transaction() { +class UpdateNsIdTemporaryBasalTransaction(val temporaryBasal: TemporaryBasal) : Transaction() { override fun run() { - val current = database.temporaryBasalDao.findById(bolus.id) - if (current != null && current.interfaceIDs.nightscoutId != bolus.interfaceIDs.nightscoutId) - database.temporaryBasalDao.updateExistingEntry(bolus) + val current = database.temporaryBasalDao.findById(temporaryBasal.id) + if (current != null && current.interfaceIDs.nightscoutId != temporaryBasal.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = temporaryBasal.interfaceIDs.nightscoutId + database.temporaryBasalDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryTargetTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryTargetTransaction.kt index 419fba854d..28bd4211d6 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryTargetTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTemporaryTargetTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdTemporaryTargetTransaction(val temporaryTarget: TemporaryTarget) override fun run() { val current = database.temporaryTargetDao.findById(temporaryTarget.id) - if (current != null && current.interfaceIDs.nightscoutId != temporaryTarget.interfaceIDs.nightscoutId) - database.temporaryTargetDao.updateExistingEntry(temporaryTarget) + if (current != null && current.interfaceIDs.nightscoutId != temporaryTarget.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = temporaryTarget.interfaceIDs.nightscoutId + database.temporaryTargetDao.updateExistingEntry(current) + } } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTherapyEventTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTherapyEventTransaction.kt index 680fbe7ca3..0f04c6f81d 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTherapyEventTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UpdateNsIdTherapyEventTransaction.kt @@ -6,7 +6,9 @@ class UpdateNsIdTherapyEventTransaction(val therapyEvent: TherapyEvent) : Transa override fun run() { val current = database.therapyEventDao.findById(therapyEvent.id) - if (current != null && current.interfaceIDs.nightscoutId != therapyEvent.interfaceIDs.nightscoutId) - database.therapyEventDao.updateExistingEntry(therapyEvent) + if (current != null && current.interfaceIDs.nightscoutId != therapyEvent.interfaceIDs.nightscoutId) { + current.interfaceIDs.nightscoutId = therapyEvent.interfaceIDs.nightscoutId + database.therapyEventDao.updateExistingEntry(current) + } } } \ No newline at end of file