diff options
| author | LV-426 <lv-426@taproot.org.il> | 2015-05-22 16:26:48 +0300 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2015-05-22 16:26:48 +0300 |
| commit | 65ea304e813bc774d8b1cc9d60a85701d9a22d7d (patch) | |
| tree | 643c2f53ad2d213d40eba0acb9798ad4c6985284 /src | |
| parent | 43c28fcbdd40383d221dc54d45b09344a175797d (diff) | |
activity.js: handle graph element name resolution failure when missing from current graph
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/view/activity.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/client/view/activity.js b/src/client/view/activity.js index e290f16a..f37076db 100644 --- a/src/client/view/activity.js +++ b/src/client/view/activity.js @@ -46,9 +46,11 @@ function diff_to_summary_str__attr(diff) var nodes_changed, links_changed; - function collect(root, find) { + function collect(root, graph_elem_find_func) { return _.map(_.keys(root), function (id) { - var writes = root[id].__attr_write, + var e_name_or_id, + cur_graph_elem, + writes = root[id].__attr_write, ret = []; _.each(_.keys(writes), function (key) { @@ -63,7 +65,11 @@ function diff_to_summary_str__attr(diff) _.map(root[id].__attr_remove, function (id) { ret.push(id + ' removed'); }); - return find(id).name + ': ' + ret.join(', '); /* TODO: use the previous name of the node, not the new name */ + + // attempt name resolution + cur_graph_elem = graph_elem_find_func(id); + e_name_or_id = (cur_graph_elem && cur_graph_elem.name) || id; // use id as fallback, eg. when element not present in current graph + return e_name_or_id + ': ' + ret.join(', '); /* TODO: use the previous name of the node, not the new name */ }); } nodes_changed = collect(diff.__type_node, graph.find_node__by_id); |
