maps were crashing when topics were removed (if those topics included the 'root node'. this was caused by a setTimeout interfering with synchronicity of events

This commit is contained in:
Connor Turland 2015-01-11 13:30:05 -05:00
parent b2fce96974
commit 263eef52ce

View file

@ -2812,10 +2812,6 @@ Metamaps.Control = {
hideNode: function (nodeid) { hideNode: function (nodeid) {
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid); var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
var graph = Metamaps.Visualize.mGraph; var graph = Metamaps.Visualize.mGraph;
if (nodeid == Metamaps.Visualize.mGraph.root) { // && Metamaps.Visualize.type === "RGraph"
var newroot = _.find(graph.graph.nodes, function(n){ return n.id !== nodeid; });
graph.root = newroot ? newroot.id : null;
}
Metamaps.Control.deselectNode(node); Metamaps.Control.deselectNode(node);
@ -2830,6 +2826,10 @@ Metamaps.Control = {
duration: 500 duration: 500
}); });
setTimeout(function () { setTimeout(function () {
if (nodeid == Metamaps.Visualize.mGraph.root) { // && Metamaps.Visualize.type === "RGraph"
var newroot = _.find(graph.graph.nodes, function(n){ return n.id !== nodeid; });
graph.root = newroot ? newroot.id : null;
}
Metamaps.Visualize.mGraph.graph.removeNode(nodeid); Metamaps.Visualize.mGraph.graph.removeNode(nodeid);
}, 500); }, 500);
Metamaps.Filter.checkMetacodes(); Metamaps.Filter.checkMetacodes();