From bf12a7dde074ad6d688cf19b38ef9021b76d5142 Mon Sep 17 00:00:00 2001 From: DubrovinPavel Date: Mon, 25 Dec 2023 09:12:41 +0500 Subject: [PATCH] Update changed models in store after batchUpdate --- CHANGELOG.md | 3 +++ addon/adapters/odata.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a0b55c1..9295cef2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +### Fixed +- Update changed models in store after batchUpdate. + ## [3.11.0] - 2023-11-09 ### Added - Projections parameter for batchUpdate. diff --git a/addon/adapters/odata.js b/addon/adapters/odata.js index 026164ba..d80e12c0 100644 --- a/addon/adapters/odata.js +++ b/addon/adapters/odata.js @@ -578,6 +578,8 @@ export default DS.RESTAdapter.extend({ return reject(errors); } + const normalizedForPush = A(); + models.forEach((model) => { const modelDirtyType = model.get('dirtyType'); if (modelDirtyType === 'deleted') { @@ -587,6 +589,7 @@ export default DS.RESTAdapter.extend({ const id = model.get('id'); const normalized = getResponses[id]; if (!isNone(normalized)) { + normalizedForPush.addObject(normalized); const internalModel = model._internalModel; internalModel.adapterWillCommit(); internalModel.flushChangedAttributes(); @@ -600,6 +603,10 @@ export default DS.RESTAdapter.extend({ result.push(modelDirtyType === 'deleted' ? null : model); }); + normalizedForPush.forEach((record) => { + store.push(record); + }); + return resolve(result); } catch (error) { // If an error is thrown then this situation is not processed and user will get not understandable result.