From 232c6b32d79f7c374e7dcfcf1ea80a12f5aa1d28 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Wed, 20 Sep 2023 21:32:51 +0700 Subject: [PATCH 1/4] Fix issue of workspace distance rate when offline Signed-off-by: Tsaqif --- src/libs/actions/Policy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 93b46f2e53da..b6fe0975d152 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -714,13 +714,14 @@ function updateWorkspaceCustomUnitAndRate(policyID, currentCustomUnit, newCustom }, ]; + const customUnitRateParam = _.omit(newCustomUnit.rates, ['pendingAction', 'errors']); API.write( 'UpdateWorkspaceCustomUnitAndRate', { policyID, lastModified, customUnit: JSON.stringify(newCustomUnit), - customUnitRate: JSON.stringify(newCustomUnit.rates), + customUnitRate: JSON.stringify(customUnitRateParam), }, {optimisticData, successData, failureData}, ); From fbe8b0d8e91886b588791ad2a7b40c9aaa3b9192 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Wed, 20 Sep 2023 22:01:48 +0700 Subject: [PATCH 2/4] remove space and revert naming variable Signed-off-by: Tsaqif --- src/libs/actions/Policy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index b6fe0975d152..fa12d5d84b2f 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -714,14 +714,14 @@ function updateWorkspaceCustomUnitAndRate(policyID, currentCustomUnit, newCustom }, ]; - const customUnitRateParam = _.omit(newCustomUnit.rates, ['pendingAction', 'errors']); + const newCustomUnitRateParam = _.omit(newCustomUnit.rates, ['pendingAction', 'errors']); API.write( 'UpdateWorkspaceCustomUnitAndRate', { policyID, lastModified, customUnit: JSON.stringify(newCustomUnit), - customUnitRate: JSON.stringify(customUnitRateParam), + customUnitRate: JSON.stringify(newCustomUnitRateParam), }, {optimisticData, successData, failureData}, ); From 573338515ddd8129102c61fca9277cbee96212b3 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Wed, 20 Sep 2023 22:28:19 +0700 Subject: [PATCH 3/4] omiting some fields on customUnit too... Signed-off-by: Tsaqif --- src/libs/actions/Policy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index fa12d5d84b2f..ce4341fafb76 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -714,13 +714,14 @@ function updateWorkspaceCustomUnitAndRate(policyID, currentCustomUnit, newCustom }, ]; + const newCustomUnitParam = _.omit(newCustomUnit, ['pendingAction', 'errors']); const newCustomUnitRateParam = _.omit(newCustomUnit.rates, ['pendingAction', 'errors']); API.write( 'UpdateWorkspaceCustomUnitAndRate', { policyID, lastModified, - customUnit: JSON.stringify(newCustomUnit), + customUnit: JSON.stringify(newCustomUnitParam), customUnitRate: JSON.stringify(newCustomUnitRateParam), }, {optimisticData, successData, failureData}, From 5420435104a2515e87ed61d87844a1a5770cbdc8 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Thu, 21 Sep 2023 06:01:56 +0700 Subject: [PATCH 4/4] clone newCustomUnit... Signed-off-by: Tsaqif --- src/libs/actions/Policy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index ce4341fafb76..e42ef1ac4823 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -714,15 +714,15 @@ function updateWorkspaceCustomUnitAndRate(policyID, currentCustomUnit, newCustom }, ]; - const newCustomUnitParam = _.omit(newCustomUnit, ['pendingAction', 'errors']); - const newCustomUnitRateParam = _.omit(newCustomUnit.rates, ['pendingAction', 'errors']); + const newCustomUnitParam = _.clone(newCustomUnit); + newCustomUnitParam.rates = _.omit(newCustomUnitParam.rates, ['pendingAction', 'errors']); API.write( 'UpdateWorkspaceCustomUnitAndRate', { policyID, lastModified, customUnit: JSON.stringify(newCustomUnitParam), - customUnitRate: JSON.stringify(newCustomUnitRateParam), + customUnitRate: JSON.stringify(newCustomUnitParam.rates), }, {optimisticData, successData, failureData}, );