ignore previous node state/flush states on topo change

This commit is contained in:
David Kaltschmidt
2015-09-11 11:03:59 +02:00
parent 72c433eb86
commit 6c5c2c2c94

View File

@@ -48,11 +48,14 @@ const NodesChart = React.createClass({
},
componentWillReceiveProps: function(nextProps) {
if (nextProps.nodes !== this.props.nodes) {
// wipe node states when showing different topology
if (nextProps.topologyId !== this.props.topologyId) {
this.setState({
nodes: {},
edges: {}
});
}
if (nextProps.nodes !== this.props.nodes) {
this.updateGraphState(nextProps);
}
if (this.props.selectedNodeId !== nextProps.selectedNodeId) {
@@ -151,13 +154,13 @@ const NodesChart = React.createClass({
);
},
initNodes: function(topology, prevNodes) {
initNodes: function(topology) {
const centerX = this.props.width / 2;
const centerY = this.props.height / 2;
const nodes = {};
topology.forEach(function(node, id) {
nodes[id] = prevNodes[id] || {};
nodes[id] = {};
// use cached positions if available
_.defaults(nodes[id], {