Browse Source

fix: workflow is execute when the schedule is missed

Ahmad Kholid 3 years ago
parent
commit
6f8cec8cf1
2 changed files with 9 additions and 1 deletions
  1. 6 0
      src/background/index.js
  2. 3 1
      src/composable/hasPermissions.js

+ 6 - 0
src/background/index.js

@@ -320,6 +320,12 @@ browser.alarms.onAlarm.addListener(async ({ name }) => {
 
 
       return;
       return;
     }
     }
+  } else if (data && data.type === 'date') {
+    const [hour, minute] = data.time.split(':');
+    const date = dayjs(data.date).hour(hour).minute(minute).second(0);
+
+    const isAfter = dayjs().isAfter(date);
+    if (isAfter) return;
   }
   }
 
 
   workflow.execute(currentWorkflow);
   workflow.execute(currentWorkflow);

+ 3 - 1
src/composable/hasPermissions.js

@@ -23,7 +23,9 @@ export function useHasPermissions(permissions) {
 
 
         if (needReload) {
         if (needReload) {
           alert('Automa needs to reload to make this feature work');
           alert('Automa needs to reload to make this feature work');
-          browser.runtime.reload();
+          browser.runtime.getBackgroundPage().then((background) => {
+            background.location.reload();
+          });
         }
         }
       })
       })
       .catch((error) => {
       .catch((error) => {