-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only remove deleted records form record arrays when saved #3539
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,11 +57,12 @@ export default Ember.Object.extend({ | |
@method updateRecordArrays | ||
*/ | ||
updateRecordArrays: function() { | ||
this.changedRecords.forEach((record) => { | ||
if (record.isDeleted()) { | ||
this._recordWasDeleted(record); | ||
this.changedRecords.forEach((internalModel) => { | ||
if (get(internalModel, 'record.isDestroyed') || get(internalModel, 'record.isDestroying') || | ||
(get(internalModel, 'currentState.stateName') === 'root.deleted.saved')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
this._recordWasDeleted(internalModel); | ||
} else { | ||
this._recordWasChanged(record); | ||
this._recordWasChanged(internalModel); | ||
} | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,8 +156,10 @@ ManyRelationship.prototype.findRecords = function() { | |
//TODO CLEANUP | ||
return this.store.findMany(this.manyArray.toArray().map((rec) => rec._internalModel)). | ||
then(() => { | ||
//Goes away after the manyArray refactor | ||
this.manyArray.set('isLoaded', true); | ||
if (!this.manyArray.get('isDestroyed')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems scary, why is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied it from this code https://github.com/bmac/data/blob/rebase-3247/packages/ember-data/lib/system/relationships/state/has-many.js#L187-L189. I think with the async code its possible to get into a state where the relationship is cleaned up before the |
||
//Goes away after the manyArray refactor | ||
this.manyArray.set('isLoaded', true); | ||
} | ||
return this.manyArray; | ||
}); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also do this on dematerialize, so it will be called twice now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I remove the
internalModel.clearRelationships();
from theunloadRecord
methods?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I would rely on it there, and not here, but I think we can fix that later when I merge the unload refactor