Skip to content

Commit

Permalink
fix: workflows not showing up in website
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 committed Jan 25, 2022
1 parent aece9ef commit d455092
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "automa",
"version": "0.16.1",
"version": "0.16.2",
"description": "An extension for automating your browser by connecting blocks",
"license": "MIT",
"repository": {
Expand Down
14 changes: 0 additions & 14 deletions src/content/services/index.js

This file was deleted.

9 changes: 6 additions & 3 deletions src/content/services/shortcut-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ function getTriggerBlock(workflow) {
return trigger;
}

export default async function (workflows) {
(async () => {
try {
const { shortcuts } = await browser.storage.local.get('shortcuts');
const { shortcuts, workflows } = await browser.storage.local.get([
'shortcuts',
'workflows',
]);
const shortcutsArr = Object.entries(shortcuts || {});

if (shortcutsArr.length === 0) return;
Expand Down Expand Up @@ -52,4 +55,4 @@ export default async function (workflows) {
} catch (error) {
console.error(error);
}
}
})();
20 changes: 7 additions & 13 deletions src/content/services/web-service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { openDB } from 'idb';
import { nanoid } from 'nanoid';
import secrets from 'secrets';
import browser from 'webextension-polyfill';
import { objectHasKey } from '@/utils/helper';
import { sendMessage } from '@/utils/message';
Expand All @@ -23,10 +22,14 @@ function initWebListener() {
return { on };
}

async function listenWindowMessage(workflows) {
(async () => {
try {
if (secrets?.webOrigin.includes(window.location.origin)) return;
document.body.setAttribute(
'data-atm-ext-installed',
browser.runtime.getManifest().version
);

const { workflows } = await browser.storage.local.get('workflows');
const db = await openDB('automa', 1, {
upgrade(event) {
event.createObjectStore('store');
Expand Down Expand Up @@ -61,13 +64,4 @@ async function listenWindowMessage(workflows) {
} catch (error) {
console.error(error);
}
}

export default async function (workflows) {
await listenWindowMessage(workflows);

document.body.setAttribute(
'data-atm-ext-installed',
browser.runtime.getManifest().version
);
}
})();
12 changes: 11 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@
"<all_urls>"
],
"js": [
"services.bundle.js"
"shortcutListener.bundle.js"
],
"run_at": "document_end",
"all_frames": false
},
{
"matches": [
"*://*.automa.site/*",
"*://automa.vercel.app/*"
],
"js": [
"webService.bundle.js"
],
"all_frames": false
}
],
"permissions": [
Expand Down
6 changes: 5 additions & 1 deletion src/newtab/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const retrieved = ref(false);
const currentVersion = browser.runtime.getManifest().version;
const prevVersion = localStorage.getItem('ext-version') || '0.0.0';
const isUpdated = ref(compare(currentVersion, prevVersion, '>'));
const isUpdated = ref(false);
function handleStorageChanged(change) {
if (change.logs) {
Expand Down Expand Up @@ -71,6 +71,10 @@ window.addEventListener('beforeunload', () => {
onMounted(async () => {
try {
const { isFirstTime } = await browser.storage.local.get('isFirstTime');
isUpdated.value = !isFirstTime && compare(currentVersion, prevVersion, '>');
await store.dispatch('retrieve', ['workflows', 'logs', 'collections']);
await store.dispatch('retrieveWorkflowState');
Expand Down
22 changes: 20 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@ const options = {
popup: path.join(__dirname, 'src', 'popup', 'index.js'),
background: path.join(__dirname, 'src', 'background', 'index.js'),
contentScript: path.join(__dirname, 'src', 'content', 'index.js'),
services: path.join(__dirname, 'src', 'content', 'services', 'index.js'),
shortcutListener: path.join(
__dirname,
'src',
'content',
'services',
'shortcut-listener.js'
),
webService: path.join(
__dirname,
'src',
'content',
'services',
'web-service.js'
),
elementSelector: path.join(
__dirname,
'src',
Expand All @@ -53,7 +66,12 @@ const options = {
),
},
chromeExtensionBoilerplate: {
notHotReload: ['contentScript', 'services', 'elementSelector'],
notHotReload: [
'contentScript',
'webService',
'shortcutListener',
'elementSelector',
],
},
output: {
path: path.resolve(__dirname, 'build'),
Expand Down

0 comments on commit d455092

Please sign in to comment.