From a6a287124a7e4d8c97d25b20c30329c195e0f367 Mon Sep 17 00:00:00 2001 From: Scott Newcomer Date: Mon, 27 Dec 2021 14:51:53 -0600 Subject: [PATCH] rm REMOVE_RECORD_ARRAY_MANAGER_LEGACY_COMPAT branches --- .../-private/system/model/internal-model.ts | 20 ++---------- .../-private/system/record-array-manager.js | 32 ++----------------- 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/packages/store/addon/-private/system/model/internal-model.ts b/packages/store/addon/-private/system/model/internal-model.ts index b0bb16ed450..96e304deec5 100644 --- a/packages/store/addon/-private/system/model/internal-model.ts +++ b/packages/store/addon/-private/system/model/internal-model.ts @@ -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, @@ -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'; @@ -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); } @@ -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() { @@ -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; diff --git a/packages/store/addon/-private/system/record-array-manager.js b/packages/store/addon/-private/system/record-array-manager.js index 2a0af1e07ab..c7b43173659 100644 --- a/packages/store/addon/-private/system/record-array-manager.js +++ b/packages/store/addon/-private/system/record-array-manager.js @@ -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'; @@ -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 @@ -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); }; @@ -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; } @@ -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 {