fix bug in add flow
diff --git a/web/ons-demo/js/app.js b/web/ons-demo/js/app.js
index 02dbc5d..144a1d2 100644
--- a/web/ons-demo/js/app.js
+++ b/web/ons-demo/js/app.js
@@ -231,13 +231,11 @@
var newSelectedFlows = [];
selectedFlows.forEach(function (flow) {
if (flow) {
- if (flow.pending) {
+ var liveFlow = flowMap[makeFlowKey(flow)];
+ if (liveFlow) {
+ newSelectedFlows.push(liveFlow);
+ } else if (flow.pending) {
newSelectedFlows.push(flow);
- } else {
- var liveFlow = flowMap[makeFlowKey(flow)];
- if (liveFlow) {
- newSelectedFlows.push(liveFlow);
- }
}
} else {
newSelectedFlows.push(null);
@@ -269,11 +267,13 @@
}
}
-function deselectFlow(flow) {
+function deselectFlow(flow, ifPending) {
var flowKey = makeFlowKey(flow);
var newSelectedFlows = [];
selectedFlows.forEach(function (flow) {
- if (!flow || flowKey !== makeFlowKey(flow)) {
+ if (!flow ||
+ flowKey !== makeFlowKey(flow) ||
+ flowKey === makeFlowKey(flow) && ifPending && !flow.pending ) {
newSelectedFlows.push(flow);
}
});
@@ -285,6 +285,10 @@
updateSelectedFlows();
}
+function deselectFlowIfPending(flow) {
+ deselectFlow(flow, true);
+}
+
function showFlowChooser() {
function rowEnter(d) {
var row = d3.select(this);
@@ -802,7 +806,7 @@
selectFlow(flow);
setTimeout(function () {
- deselectFlow(flow);
+ deselectFlowIfPending(flow);
}, pendingTimeout);
}
} else {