Selaa lähdekoodia

fix: execute workflow event listener

Ahmad Kholid 1 vuosi sitten
vanhempi
commit
a1be1c47fe
1 muutettua tiedostoa jossa 16 lisäystä ja 17 poistoa
  1. 16 17
      src/content/services/shortcutListener.js

+ 16 - 17
src/content/services/shortcutListener.js

@@ -7,23 +7,22 @@ Mousetrap.prototype.stopCallback = function () {
 };
 
 function automaCustomEventListener(findWorkflow) {
-  window.addEventListener(
-    'automa:execute-workflow',
-    ({ detail }) => {
-      if (!detail || (!detail.id && !detail.publicId)) return;
-
-      const workflowId = detail.id || detail.publicId;
-      const workflow = findWorkflow(workflowId, Boolean(detail.publicId));
-
-      if (!workflow) return;
-
-      workflow.options = {
-        data: detail.data || {},
-      };
-      sendMessage('workflow:execute', workflow, 'background');
-    },
-    true
-  );
+  function customEventListener({ detail }) {
+    if (!detail || (!detail.id && !detail.publicId)) return;
+
+    const workflowId = detail.id || detail.publicId;
+    const workflow = findWorkflow(workflowId, Boolean(detail.publicId));
+
+    if (!workflow) return;
+
+    workflow.options = {
+      data: detail.data || {},
+    };
+    sendMessage('workflow:execute', workflow, 'background');
+  }
+
+  window.addEventListener('__automaExecuteWorkflow', customEventListener);
+  window.addEventListener('automa:execute-workflow', customEventListener);
 }
 function workflowShortcutsListener(findWorkflow, shortcutsObj) {
   const shortcuts = Object.entries(shortcutsObj);