Skip to content

Commit

Permalink
rm REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT branches
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Dec 27, 2021
1 parent 57b2e80 commit a6a2871
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 47 deletions.
20 changes: 2 additions & 18 deletions packages/store/addon/-private/system/model/internal-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DEBUG } from '@glimmer/env';

import RSVP, { Promise } from 'rsvp';

import { RECORD_DATA_ERRORS, REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT } from '@ember-data/canary-features';
import { RECORD_DATA_ERRORS } from '@ember-data/canary-features';
import { HAS_MODEL_PACKAGE, HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
import type {
BelongsToRelationship,
Expand All @@ -27,7 +27,6 @@ import type { ConfidentDict } from '../../ts-interfaces/utils';
import type CoreStore from '../core-store';
import type Store from '../ds-model-store';
import { errorsHashToArray } from '../errors-utils';
import { recordArraysForIdentifier } from '../record-array-manager';
import recordDataFor from '../record-data-for';
import { BelongsToReference, HasManyReference, RecordReference } from '../references';
import Snapshot from '../snapshot';
Expand Down Expand Up @@ -278,9 +277,6 @@ export default class InternalModel {
this._doNotDestroy = false;
// this has to occur before the internal model is removed
// for legacy compat.
if (!REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT) {
this.store.recordArrayManager.recordDidChange(this.identifier);
}
if (this._record) {
this.store.teardownRecord(this._record);
}
Expand All @@ -306,9 +302,7 @@ export default class InternalModel {
this.error = null;
this._previousState = this.currentState;
this.currentState = RootState.empty;
if (REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT) {
this.store.recordArrayManager.recordDidChange(this.identifier);
}
this.store.recordArrayManager.recordDidChange(this.identifier);
}

deleteRecord() {
Expand Down Expand Up @@ -1172,16 +1166,6 @@ export default class InternalModel {
}
}

// in production code, this is only accesssed in `record-array-manager`
// if REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT is also false
if (!REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT) {
Object.defineProperty(InternalModel.prototype, '_recordArrays', {
get() {
return recordArraysForIdentifier(this.identifier);
},
});
}

function handleCompletedRelationshipRequest(internalModel, key, relationship, value, error) {
delete internalModel._relationshipPromisesCache[key];
relationship.state.shouldForceReload = false;
Expand Down
32 changes: 3 additions & 29 deletions packages/store/addon/-private/system/record-array-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { assert } from '@ember/debug';
import { get, set } from '@ember/object';
import { _backburner as emberBackburner } from '@ember/runloop';

import { REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT } from '@ember-data/canary-features';

import isStableIdentifier from '../identifiers/is-stable-identifier';
import { AdapterPopulatedRecordArray, RecordArray } from './record-arrays';
import { internalModelFactoryFor } from './store/internal-model-factory';
Expand All @@ -31,7 +29,7 @@ const IMDematerializing = new WeakMap();

const getIdentifier = function getIdentifier(identifierOrInternalModel) {
let i = identifierOrInternalModel;
if (!REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT && !isStableIdentifier(identifierOrInternalModel)) {
if (!isStableIdentifier(identifierOrInternalModel)) {
// identifier may actually be an internalModel
// but during materialization we will get an identifier that
// has already been removed from the identifiers cache yet
Expand All @@ -42,18 +40,7 @@ const getIdentifier = function getIdentifier(identifierOrInternalModel) {
return i;
};

// REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT only
const peekIMCache = function peekIMCache(cache, identifier) {
if (!REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT) {
let im = IMDematerializing.get(identifier);
if (im === undefined) {
// if not im._isDematerializing
im = cache.peek(identifier);
}

return im;
}

return cache.peek(identifier);
};

Expand Down Expand Up @@ -351,14 +338,6 @@ class RecordArrayManager {
let modelName = identifier.type;
identifier = getIdentifier(identifier);

if (!REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT) {
const cache = internalModelFactoryFor(this.store);
const im = peekIMCache(cache, identifier);
if (im && im._isDematerializing) {
IMDematerializing.set(identifier, im);
}
}

if (pendingForIdentifier.has(identifier)) {
return;
}
Expand Down Expand Up @@ -428,15 +407,10 @@ const updateLiveRecordArray = function updateLiveRecordArray(store, recordArray,
};

const pushIdentifiers = function pushIdentifiers(recordArray, identifiers, cache) {
if (!REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT && !recordArray._pushIdentifiers) {
// deprecate('not allowed to use this intimate api any more');
recordArray._pushInternalModels(identifiers.map((i) => peekIMCache(cache, i)));
} else {
recordArray._pushIdentifiers(identifiers);
}
recordArray._pushIdentifiers(identifiers);
};
const removeIdentifiers = function removeIdentifiers(recordArray, identifiers, cache) {
if (!REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT && !recordArray._removeIdentifiers) {
if (!recordArray._removeIdentifiers) {
// deprecate('not allowed to use this intimate api any more');
recordArray._removeInternalModels(identifiers.map((i) => peekIMCache(cache, i)));
} else {
Expand Down

0 comments on commit a6a2871

Please sign in to comment.