Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

[Scopes] expanded properties are not updated while stepping #2509

Merged
merged 11 commits into from Apr 5, 2017
1 change: 1 addition & 0 deletions src/components/Editor/Preview.js
Expand Up @@ -100,6 +100,7 @@ class Preview extends Component {
onDoubleClick: () => {},
loadObjectProperties,
getActors: () => ({}),
setActors: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

this will return undefined, should be setActors: () => ({}) instead

});
}

Expand Down
1 change: 1 addition & 0 deletions src/components/SecondaryPanes/Expressions.js
Expand Up @@ -162,6 +162,7 @@ class Expressions extends React.Component {
this.editExpression(expression, options),
loadObjectProperties,
getActors: () => ({}),
setActors: () => {},
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

}),
CloseButton({ handleClick: e => this.deleteExpression(e, expression) })
);
Expand Down
24 changes: 22 additions & 2 deletions src/components/shared/ObjectInspector.js
Expand Up @@ -35,7 +35,7 @@ type ObjectInspectorItemContents = {
};

type ObjectInspectorItem = {
contents: Array<ObjectInspectorItem> & ObjectInspectorItemContents,
contents: ObjectInspectorItemContents & Array<ObjectInspectorItem>,
name: string,
path: string,
};
Expand Down Expand Up @@ -86,7 +86,7 @@ const ObjectInspector = React.createClass({
getExpanded: PropTypes.func,
setExpanded: PropTypes.func,
getActors: PropTypes.func.isRequired,
setActors: PropTypes.func,
setActors: PropTypes.func.isRequired,
},

actors: (null: any),
Expand Down Expand Up @@ -122,6 +122,26 @@ const ObjectInspector = React.createClass({
getChildren(item: ObjectInspectorItem) {
const { getObjectProperties } = this.props;
const { actors } = this;
const key = item.path;

if (item.contents.value && item.contents.value.preview && actors[key]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny note, just for security ... actors && actors[key]

const properties = item.contents.value.preview.ownProperties;
let thisActor = actors[key];
for (let pKey in properties) {
if (properties.hasOwnProperty(pKey)) {
const cacheObject = thisActor.filter(a => a.name == pKey)[0];
const cacheObjectIndex = thisActor.findIndex(a => a.name == pKey);
// Assign new values to the cache actor if it becomes stale
if (
cacheObject && cacheObject.contents.value != properties[pKey].value
) {
thisActor[cacheObjectIndex].contents = properties[pKey];
}
}
}
actors[key] = thisActor;
this.props.setActors(actors);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we can simplify the cache significantly.

The way i see it working is that it would keep a key of IDs that are expanded and that's it. This way, values don't need to be synced...

}
Copy link
Contributor

Choose a reason for hiding this comment

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

can this move to utils/object-inspector and get some unit tests?


return getChildren({
getObjectProperties,
Expand Down
14 changes: 1 addition & 13 deletions src/utils/object-inspector.js
Expand Up @@ -181,19 +181,7 @@ function getChildren(
// node would be a new instance every render.
const key = item.path;
if (actors && actors[key]) {
const properties = item.contents.value.preview.ownProperties;
let thisActor = actors[key];
for (let pKey in properties) {
if (properties.hasOwnProperty(pKey)) {
const cacheObject = thisActor.filter(a => a.name == pKey)[0];
const cacheObjectIndex = thisActor.findIndex(a => a.name == pKey);
// Assign new values to the cache actor if it becomes stale
if (cacheObject && getValue(cacheObject) != properties[pKey].value) {
thisActor[cacheObjectIndex].contents = properties[pKey];
}
}
}
return thisActor;
return actors[key];
}

if (isBucket(item)) {
Expand Down