Skip to content

Commit

Permalink
Update changed models in store after batchUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
DubrovinPavel committed Dec 25, 2023
1 parent 8694213 commit bf12a7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 7 additions & 0 deletions addon/adapters/odata.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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();
Expand All @@ -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.
Expand Down

0 comments on commit bf12a7d

Please sign in to comment.