Remove when.js from runtime/lib/flow/index

This commit is contained in:
Nick O'Leary
2020-09-29 17:20:01 +01:00
parent 22a301b55e
commit ea45dde63a
2 changed files with 131 additions and 169 deletions

View File

@@ -15,7 +15,6 @@
**/
var clone = require("clone");
var when = require("when");
var Flow = require('./Flow');
@@ -488,7 +487,7 @@ function updateMissingTypes() {
}
}
function addFlow(flow, user) {
async function addFlow(flow, user) {
var i,node;
if (!flow.hasOwnProperty('nodes')) {
throw new Error('missing nodes property');
@@ -513,10 +512,10 @@ function addFlow(flow, user) {
node = flow.nodes[i];
if (activeFlowConfig.allNodes[node.id]) {
// TODO nls
return when.reject(new Error('duplicate id'));
throw new Error('duplicate id');
}
if (node.type === 'tab' || node.type === 'subflow') {
return when.reject(new Error('invalid node type: '+node.type));
throw new Error('invalid node type: '+node.type);
}
node.z = flow.id;
nodes.push(node);
@@ -526,10 +525,10 @@ function addFlow(flow, user) {
node = flow.configs[i];
if (activeFlowConfig.allNodes[node.id]) {
// TODO nls
return when.reject(new Error('duplicate id'));
throw new Error('duplicate id');
}
if (node.type === 'tab' || node.type === 'subflow') {
return when.reject(new Error('invalid node type: '+node.type));
throw new Error('invalid node type: '+node.type);
}
node.z = flow.id;
nodes.push(node);
@@ -614,7 +613,7 @@ function getFlow(id) {
return result;
}
function updateFlow(id,newFlow, user) {
async function updateFlow(id,newFlow, user) {
var label = id;
if (id !== 'global') {
if (!activeFlowConfig.flows[id]) {
@@ -674,7 +673,7 @@ function updateFlow(id,newFlow, user) {
})
}
function removeFlow(id, user) {
async function removeFlow(id, user) {
if (id === 'global') {
// TODO: nls + error code
throw new Error('not allowed to remove global');