Skip to content

Commit

Permalink
Automatically reload options when the extension reloads (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed May 5, 2023
1 parent b59df3f commit d54d1c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/esm-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- uses: actions/download-artifact@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16
- run: echo "${{ env.IMPORT_TEXT }} '${{ env.NPM_MODULE_NAME }}'" > index.mjs
- run: npm install ./artifact
- run: node index.mjs
5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import chromeP from 'webext-polyfill-kinda';
import {isBackground} from 'webext-detect-page';
import {serialize, deserialize} from 'dom-form-serializer/dist/dom-form-serializer.mjs';
import LZString from 'lz-string';
import {onContextInvalidated} from 'webext-events';
import {loadFile, saveFile} from './file.js';

// eslint-disable-next-line @typescript-eslint/naming-convention -- CJS in ESM imports
Expand Down Expand Up @@ -182,6 +183,10 @@ class OptionsSync<UserOptions extends Options> {

this._form.querySelector('.js-export')?.addEventListener('click', this.exportToFile);
this._form.querySelector('.js-import')?.addEventListener('click', this.importFromFile);

onContextInvalidated.addListener(() => {
location.reload();
});
}

/**
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"lz-string": "^1.4.4",
"throttle-debounce": "^5.0.0",
"webext-detect-page": "^4.0.1",
"webext-events": "^1.1.0",
"webext-polyfill-kinda": "^1.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit d54d1c1

Please sign in to comment.