@@ -7,15 +7,15 @@ import type { Passage, Story } from "~/raem/redux/Bard";
77import { HostRef , UnpackedHostValue } from "~/raem/VALK/hostReference" ;
88
99import { addedTo , fieldsSet , isCreatedLike , removedFrom , replacedWithin } from "~/raem/events" ;
10- import { VRef , vRef , invariantifyId , getRawIdFrom , tryCoupledFieldFrom , expandIdDataFrom ,
11- obtainVRef } from "~/raem/ValaaReference" ;
10+ import { VRef , vRef , invariantifyId , getRawIdFrom , tryCoupledFieldFrom , expandIdDataFrom }
11+ from "~/raem/ValaaReference" ;
1212import { createPartitionURI , getPartitionRawIdFrom } from "~/raem/ValaaURI" ;
1313
1414import dataFieldValue from "~/raem/tools/denormalized/dataFieldValue" ;
1515
1616import { Resolver , State , Transient } from "~/raem/state" ;
1717import { tryElevateFieldValue } from "~/raem/state/FieldInfo" ;
18- import getObjectTransient from "~/raem/state/getObjectTransient" ;
18+ import getObjectTransient , { getObjectTransientDetailed } from "~/raem/state/getObjectTransient" ;
1919import { getObjectRawField } from "~/raem/state/getObjectField" ;
2020
2121import { createGhostVRefInInstance , isMaterialized , createMaterializeGhostAction }
@@ -553,19 +553,23 @@ export default class Vrapper extends Cog {
553553 const explicitState = options.state
554554 || (options.transaction && options.transaction.getState())
555555 || (options.withOwnField && this.engine.discourse.getState());
556+ const discourse = options.transaction || this.engine.discourse;
556557 if (explicitState) {
557558 const typeName = options.typeName || this.getTypeName(options);
558559 const ret = explicitState.getIn([typeName, this.getRawId()]);
559560 if (ret && (!options.withOwnField || ret.has(options.withOwnField))) return ret;
560561 // Immaterial ghost.
561- return getObjectTransient(options.state || options.transaction || this.engine.discourse,
562+ return getObjectTransientDetailed(
563+ !options.state ? discourse
564+ : Object.assign(Object.create(discourse), { state: options.state }),
562565 this[HostRef], typeName, undefined,
563566 options.require, options.mostMaterialized, options.withOwnField);
564567 }
565568 if (this._transientStaledIn) {
566569 this.updateTransient(null,
567- getObjectTransient(this._transientStaledIn, this.getId(),
568- options.typeName || this.getTypeName(options), undefined,
570+ getObjectTransientDetailed(
571+ Object.assign(Object.create(discourse), { state: this._transientStaledIn }),
572+ this.getId(), options.typeName || this.getTypeName(options), undefined,
569573 options.require, options.mostMaterialized, options.withOwnField));
570574 }
571575 return this._transient;
@@ -581,9 +585,8 @@ export default class Vrapper extends Cog {
581585
582586 materialize (transaction: ?Transaction): ChronicleEventResult {
583587 const discourse = (transaction || this.engine.discourse);
584- const state = discourse.getState();
585- this.requireActive({ state });
586- return discourse.chronicleEvent(createMaterializeGhostAction(state, this.getId()));
588+ this.requireActive({ state: discourse.getState() });
589+ return discourse.chronicleEvent(createMaterializeGhostAction(discourse, this.getId()));
587590 }
588591
589592 updateTransient (state: ?Object, object: ?Object) {
@@ -942,7 +945,7 @@ export default class Vrapper extends Cog {
942945 if (defaultCoupledField) {
943946 return newValue instanceof Vrapper
944947 ? newValue.getIdCoupledWith(defaultCoupledField)
945- : obtainVRef (newValue, defaultCoupledField);
948+ : this.engine.discourse.obtainReference (newValue, defaultCoupledField);
946949 }
947950 }
948951 return newValue;
0 commit comments