Skip to content
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

[CLEANUP] PERF prevent duplicate recordArrayManager signals on push o… #5151

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions addon/-private/system/model/internal-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ export default class InternalModel {

resetRecord() {
this._record = null;
this.dataHasInitialized = false;
this.isReloading = false;
this.error = null;
this.currentState = RootState.empty;
Expand Down Expand Up @@ -592,18 +591,6 @@ export default class InternalModel {
if (this.hasRecord) {
this._record._notifyProperties(changedKeys);
}
this.didInitializeData();
}

becameReady() {
this.store.recordArrayManager.recordWasLoaded(this);
}

didInitializeData() {
if (!this.dataHasInitialized) {
this.becameReady();
this.dataHasInitialized = true;
}
}

get isDestroyed() {
Expand Down Expand Up @@ -638,7 +625,6 @@ export default class InternalModel {
*/
loadedData() {
this.send('loadedData');
this.didInitializeData();
}

/*
Expand Down Expand Up @@ -785,14 +771,6 @@ export default class InternalModel {
this.didCleanError();
}

//Eventually rollback will always work for relationships
//For now we support it only out of deleted state, because we
//have an explicit way of knowing when the server acked the relationship change
if (this.isDeleted()) {
//TODO: Should probably move this to the state machine somehow
this.becameReady();
}

if (this.isNew()) {
this.removeFromInverseRelationships(true);
}
Expand Down
8 changes: 7 additions & 1 deletion addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2017,9 +2017,15 @@ Store = Service.extend({
heimdall.increment(_load);
let internalModel = this._internalModelForId(data.type, data.id);

let isUpdate = internalModel.currentState.isEmpty === false;

internalModel.setupData(data);

this.recordArrayManager.recordDidChange(internalModel);
if (isUpdate) {
this.recordArrayManager.recordDidChange(internalModel);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously, when pushing a new record this was firing, even though a new record has no updates. It merely starts off its existence in that state...

This resulted in every new record going through the record-array manager twice on initial push...

} else {
this.recordArrayManager.recordWasLoaded(internalModel);
}

return internalModel;
},
Expand Down