summaryrefslogtreecommitdiff
path: root/src/client/textanalysis.js
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-12-23 21:53:46 +0200
committerAlon Levy <alon@pobox.com>2014-12-23 22:03:17 +0200
commitf7ff8bc38410c2666665c4c70cc71c17f6eb7835 (patch)
tree458bd97cf23a2672102d85babe1deaa2ec581233 /src/client/textanalysis.js
parent3e3944c42517a2745d9dd2312e8c3a571de41863 (diff)
use topo_diff for user input changes
pretty large commit, but it mainly boils to - reusing the same format clone returns to the client for topo_diff bad bad code introduced mainly in client side, but server wasn't spared: - graph/commit_topo__diff massages the links too much - this should not be there at all, it should be in the correct format to begin with. server code duplication between clone & topo_diff post processing, should be factored out on the good side: single transaction whenever user presses enter, and the correct place to send back any accumulated diffs (other user changes).
Diffstat (limited to 'src/client/textanalysis.js')
-rw-r--r--src/client/textanalysis.js36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/client/textanalysis.js b/src/client/textanalysis.js
index 7881a767..63287913 100644
--- a/src/client/textanalysis.js
+++ b/src/client/textanalysis.js
@@ -467,17 +467,19 @@ var textAnalyser = function (newtext, finalize) {
graph.removeNodes(function(n){ return "temp" == n.state; });
graph.removeLinks("temp");
- ret.for_each_node_add(function (node) {
- if (true == finalize && node.state == 'temp') {
- console.log('bug: temp node creation on finalize');
- } else {
- if (!finalize) {
- lastnode = graph.addNode(node);
+ if (!finalize) { // finalize done via topo diff below
+ ret.for_each_node_add(function (node) {
+ if (true == finalize && node.state == 'temp') {
+ console.log('bug: temp node creation on finalize');
} else {
- graph.addNode(node);
+ if (!finalize) {
+ lastnode = graph.addNode(node);
+ } else {
+ graph.addNode(node);
+ }
}
- }
- });
+ });
+ }
}
ret.for_each_link_add(function (link) {
if (false == finalize || link.name !== 'and') {
@@ -499,13 +501,19 @@ var textAnalyser = function (newtext, finalize) {
// broadcast diff:
// - finalize?
// - broadcast_diff requested by caller
- var topo_diff = model_util.adapt_format_write_topo_diff(ret.nodes, ret.links);
- var diff_set = model_diff.new_diff_set();
- diff_set.add_diff_obj(topo_diff);
- graph.commit_diff_set(diff_set);
+ var on_success = function (ret) {
+ console.dir(ret);
+ rz_core.update_view__graph();
+ }
+ var on_error = function () {
+ console.log('askeeeeeeeeeeeeew');
+ }
+ // drop bubble node
+ ret.node_set_add = ret.node_set_add.filter(function(n) { return n.type != 'bubble'; });
+ graph.commit_diff__topo(ret, on_success, on_error);
}
- // UPDATE GRAPH ONCE
+ // update graph if not going through backend
rz_core.update_view__graph(!finalize && comp.graph_same);
};