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: () => ({}),
});
}

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: () => ({}),
}),
CloseButton({ handleClick: e => this.deleteExpression(e, expression) })
);
Expand Down
29 changes: 27 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,31 @@ 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 &&
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