Browse Source

fix: Wait for connections block doesn't continue if the flow that was connected to it changes (#881)

Ahmad Kholid 2 years ago
parent
commit
61bb6234df
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/newtab/workflowEngine/blocksHandler/handlerWaitConnections.js

+ 12 - 1
src/newtab/workflowEngine/blocksHandler/handlerWaitConnections.js

@@ -1,5 +1,5 @@
 async function waitConnections({ data, id }, { prevBlock }) {
-  return new Promise((resolve) => {
+  return new Promise((resolve, reject) => {
     let timeout;
     let resolved = false;
 
@@ -39,6 +39,17 @@ async function waitConnections({ data, id }, { prevBlock }) {
 
         clearTimeout(timeout);
 
+        if (data.specificFlow && data.flowBlockId) {
+          const connectionExist = Object.keys(
+            this.engine.waitConnections[id]
+          ).includes(data.flowBlockId);
+
+          if (!connectionExist) {
+            reject(new Error(`No specific flow selected`));
+            return;
+          }
+        }
+
         resolve({
           data: '',
           nextBlockId,