Skip to content

Commit

Permalink
[BREAKING BUGFIX] eliminate infrastructure for filter record arrays (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired authored Nov 9, 2019
1 parent db1c0ae commit 919fb21
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 43 deletions.
1 change: 0 additions & 1 deletion packages/-ember-data/tests/unit/store/asserts-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ module('unit/store/asserts - DS.Store methods produce useful assertion messages'
'_push',
'pushPayload',
'normalize',
'recordWasLoaded',
'adapterFor',
'serializerFor',
];
Expand Down
12 changes: 1 addition & 11 deletions packages/store/addon/-private/system/core-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2613,10 +2613,8 @@ abstract class CoreStore extends Service {

internalModel.setupData(data);

if (isUpdate) {
if (!isUpdate) {
this.recordArrayManager.recordDidChange(internalModel);
} else {
this.recordArrayManager.recordWasLoaded(internalModel);
}

return internalModel;
Expand Down Expand Up @@ -3143,14 +3141,6 @@ abstract class CoreStore extends Service {
return globalClientIdCounter++;
}

//Called by the state machine to notify the store that the record is ready to be interacted with
recordWasLoaded(record) {
if (DEBUG) {
assertDestroyingStore(this, 'recordWasLoaded');
}
this.recordArrayManager.recordWasLoaded(record);
}

// ...............
// . DESTRUCTION .
// ...............
Expand Down
8 changes: 0 additions & 8 deletions packages/store/addon/-private/system/model/internal-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ export default class InternalModel {
)
.finally(function() {
internalModel.finishedReloading();
internalModel.updateRecordArrays();
});
} else {
this.startedReloading();
Expand All @@ -568,7 +567,6 @@ export default class InternalModel {
)
.finally(function() {
internalModel.finishedReloading();
internalModel.updateRecordArrays();
});
}
}
Expand Down Expand Up @@ -1041,7 +1039,6 @@ export default class InternalModel {
*/
adapterDidDirty() {
this.send('becomeDirty');
this.updateRecordArrays();
}

/*
Expand Down Expand Up @@ -1087,7 +1084,6 @@ export default class InternalModel {
manyArray.retrieveLatest();
}
}
this.updateRecordArrays();
}
}

Expand All @@ -1098,7 +1094,6 @@ export default class InternalModel {
} else {
this._record.notifyBelongsToChange(key, this._record);
}
this.updateRecordArrays();
}
}

Expand All @@ -1123,7 +1118,6 @@ export default class InternalModel {
} else {
this._record.notifyPropertyChange(key);
}
this.updateRecordArrays();
}
if (!CUSTOM_MODEL_CLASS) {
let manyArray = this._manyArrayCache[key] || this._retainedManyArrayCache[key];
Expand Down Expand Up @@ -1236,8 +1230,6 @@ export default class InternalModel {
for (i = 0, l = setups.length; i < l; i++) {
setups[i].setup(this);
}

this.updateRecordArrays();
}

_unhandledEvent(state, name, context) {
Expand Down
6 changes: 4 additions & 2 deletions packages/store/addon/-private/system/model/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ function didSetProperty(internalModel, context) {
} else {
internalModel.send('propertyWasReset');
}

internalModel.updateRecordArrays();
}

// Implementation notes:
Expand Down Expand Up @@ -396,6 +394,10 @@ const createdState = dirtyState({
dirtyType: 'created',
// FLAGS
isNew: true,

setup(internalModel) {
internalModel.updateRecordArrays();
},
});

createdState.invalid.rolledBack = function(internalModel) {
Expand Down
22 changes: 1 addition & 21 deletions packages/store/addon/-private/system/record-array-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ export default class RecordArrayManager {
}

recordDidChange(internalModel) {
// TODO: change name
// TODO: track that it was also a change
this.internalModelDidChange(internalModel);
}

recordWasLoaded(internalModel) {
// TODO: change name
// TODO: track that it was also that it was first loaded
this.internalModelDidChange(internalModel);
}

internalModelDidChange(internalModel) {
let modelName = internalModel.modelName;

if (internalModel._pendingRecordArrayManagerFlush) {
Expand Down Expand Up @@ -74,7 +62,7 @@ export default class RecordArrayManager {
if (array) {
// TODO: skip if it only changed
// process liveRecordArrays
this.updateLiveRecordArray(array, internalModels);
updateLiveRecordArray(array, internalModels);
}

// process adapterPopulatedRecordArrays
Expand All @@ -92,10 +80,6 @@ export default class RecordArrayManager {
}
}

updateLiveRecordArray(array, internalModels) {
return updateLiveRecordArray(array, internalModels);
}

_syncLiveRecordArray(array, modelName) {
assert(
`recordArrayManger.syncLiveRecordArray expects modelName not modelClass as the second param`,
Expand Down Expand Up @@ -343,10 +327,6 @@ function updateLiveRecordArray(array, internalModels) {
if (modelsToRemove.length > 0) {
array._removeInternalModels(modelsToRemove);
}

// return whether we performed an update.
// Necessary until 3.5 allows us to finish off ember-data-filter support.
return (modelsToAdd.length || modelsToRemove.length) > 0;
}

function removeFromAdapterPopulatedRecordArrays(internalModels) {
Expand Down

0 comments on commit 919fb21

Please sign in to comment.