Skip to content

Commit

Permalink
Have relationship setup control its own destiny
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Nov 30, 2016
1 parent f2d7fdb commit 43abee8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1893,11 +1893,7 @@ Store = Service.extend({
if (data) {
// normalize relationship IDs into records
this.updateId(internalModel, data);

this._pushedInternalModels.push(internalModel, data);
if (this._relationshipFlush === null) {
this._relationshipFlush = this._backburner.schedule('normalizeRelationships', this, this._setupRelationships);
}
this._setupRelationshipsForModel(internalModel, data);
} else {
assert(`Your ${internalModel.type.modelName} record was saved to the server, but the response does not have an id and no id has been set client side. Records must have ids. Please update the server response to provide an id in the response or generate the id on the client side either before saving the record or while normalizing the response.`, internalModel.id);
}
Expand Down Expand Up @@ -2354,12 +2350,16 @@ Store = Service.extend({
// Actually load the record into the store.
let internalModel = this._load(data);

this._setupRelationshipsForModel(internalModel, data);

return internalModel;
},

_setupRelationshipsForModel(internalModel, data) {
this._pushedInternalModels.push(internalModel, data);
if (this._relationshipFlush === null) {
this._relationshipFlush = this._backburner.schedule('normalizeRelationships', this, this._setupRelationships);
}

return internalModel;
},

_setupRelationships() {
Expand Down

0 comments on commit 43abee8

Please sign in to comment.