Преглед на файлове

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

Ahmad Kholid преди 2 години
родител
ревизия
61bb6234df
променени са 1 файла, в които са добавени 12 реда и са изтрити 1 реда
  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,