diff options
| author | Alon Levy <alon@pobox.com> | 2015-02-11 14:34:06 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-02-11 14:34:06 +0200 |
| commit | 0dc89aa6b16412b02d76151a777c2346409bb78f (patch) | |
| tree | 7331dda0a0aacda1f931845ba0908f32fbd0b220 /src | |
| parent | 21ad53336e802dc6744098a92d1484104da310f4 (diff) | |
client/selection: update selection on added node, fixes #310
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/view/selection.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/client/view/selection.js b/src/client/view/selection.js index 65c318e1..7cade769 100644 --- a/src/client/view/selection.js +++ b/src/client/view/selection.js @@ -19,13 +19,13 @@ var root_nodes = [], // these are the nodes that are requested via update function listen_on_diff_bus(diffBus) { diffBus - .filter(".node_id_set_rm") .onValue(function (diff) { - var node_node_cmp = (function (a, b) { return a.id > b.id; }), - node_id_cmp = (function (a, b) { return a.id === b ? 0 : (a.id > b ? 1 : -1); }); - - updateSelectedNodesBus(sortedArrayDiff(selected_nodes.sort(node_node_cmp), - diff.node_id_set_rm.sort(), node_id_cmp)); + // update due to potentially removed nodes first + root_nodes = root_nodes.filter(function (n) { + return get_main_graph().find_node__by_id(n.id) !== null; + }); + // reselect based on current graph + inner_update(root_nodes); }); } @@ -142,12 +142,18 @@ function arr_compare(a1, a2) return true; } +var inner_update = function(nodes) +{ + clear(); + root_nodes = nodes; + connectedComponent(nodes); +} + var update = function(nodes) { var set = !arr_compare(nodes, root_nodes); - clear(); + if (set) { - root_nodes = nodes; - connectedComponent(nodes); + inner_update(nodes); } } |
