From 65ea304e813bc774d8b1cc9d60a85701d9a22d7d Mon Sep 17 00:00:00 2001 From: LV-426 Date: Fri, 22 May 2015 16:26:48 +0300 Subject: activity.js: handle graph element name resolution failure when missing from current graph --- src/client/view/activity.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/client/view') 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); -- cgit v1.3.1