Browse Source

fix: activeTabUrl return the same url

Ahmad Kholid 3 years ago
parent
commit
af13870886

+ 4 - 2
src/background/workflow-engine/blocks-handler/handler-delay.js

@@ -2,12 +2,14 @@ import { getBlockConnection } from '../helper';
 
 function delay(block) {
   return new Promise((resolve) => {
+    const delayTime = +block.data.time || 500;
+
     setTimeout(() => {
       resolve({
-        nextBlockId: getBlockConnection(block),
         data: '',
+        nextBlockId: getBlockConnection(block),
       });
-    }, block.data.time);
+    }, delayTime);
   });
 }
 

+ 7 - 3
src/background/workflow-engine/blocks-handler/handler-new-tab.js

@@ -26,17 +26,21 @@ async function newTab(block) {
       throw error;
     }
 
+    let tab = null;
+
     if (updatePrevTab && this.activeTab.id) {
-      await browser.tabs.update(this.activeTab.id, { url, active });
+      tab = await browser.tabs.update(this.activeTab.id, { url, active });
     } else {
-      const tab = await browser.tabs.create({
+      tab = await browser.tabs.create({
         url,
         active,
         windowId: this.windowId,
       });
+    }
 
+    this.activeTab.url = url;
+    if (tab) {
       this.activeTab.id = tab.id;
-      this.activeTab.url = url;
       this.windowId = tab.windowId;
     }
 

+ 1 - 0
src/utils/shared.js

@@ -263,6 +263,7 @@ export const tasks = {
     outputs: 1,
     allowedInputs: true,
     maxConnection: 1,
+    refDataKeys: ['time'],
     data: {
       time: 500,
     },