Browse Source

fix: infinite loop

Ahmad Kholid 3 years ago
parent
commit
a3aa8a9e02
4 changed files with 6 additions and 14 deletions
  1. 1 1
      package.json
  2. 0 9
      src/models/log.js
  3. 5 3
      src/newtab/App.vue
  4. 0 1
      src/utils/shared.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "automa",
-  "version": "1.9.0",
+  "version": "1.9.1",
   "description": "An extension for automating your browser by connecting blocks",
   "license": "MIT",
   "repository": {

+ 0 - 9
src/models/log.js

@@ -1,6 +1,5 @@
 import { Model } from '@vuex-orm/core';
 import { nanoid } from 'nanoid';
-import browser from 'webextension-polyfill';
 
 class Log extends Model {
   static entity = 'logs';
@@ -28,14 +27,6 @@ class Log extends Model {
   static afterDelete(item) {
     const logs = this.query().where('collectionLogId', item.id).get();
 
-    browser.storage.local.get('logsCtxData').then((data) => {
-      const logsCtxData = data.logsCtxData || {};
-
-      delete logsCtxData[item.id];
-
-      browser.storage.local.set({ logsCtxData });
-    });
-
     if (logs.length !== 0) {
       Promise.allSettled(logs.map(({ id }) => this.delete(id))).then(() => {
         this.store().dispatch('saveToStorage', 'workflows');

+ 5 - 3
src/newtab/App.vue

@@ -183,6 +183,7 @@ async function fetchUserData() {
     console.error(error);
   }
 }
+/* eslint-disable-next-line */
 function autoDeleteLogs() {
   const deleteAfter = store.state.settings.deleteLogAfter;
 
@@ -195,8 +196,9 @@ function autoDeleteLogs() {
   });
 }
 function handleStorageChanged(change) {
-  if (change.logs && Log.all().length !== change.logs.newValue.length) {
-    Log.insertOrUpdate({
+  if (change.logs) {
+    store.dispatch('entities/create', {
+      entity: 'logs',
       data: change.logs.newValue,
     });
   }
@@ -236,7 +238,7 @@ window.addEventListener('beforeunload', () => {
     await fetchUserData();
     await syncHostWorkflow();
 
-    autoDeleteLogs();
+    // autoDeleteLogs();
   } catch (error) {
     retrieved.value = true;
     console.error(error);

+ 0 - 1
src/utils/shared.js

@@ -924,7 +924,6 @@ export const tasks = {
     outputs: 1,
     allowedInputs: true,
     maxConnection: 1,
-    disableEdit: true,
     data: {
       disableBlock: false,
       description: '',