Skip to content

Commit 290dfba

Browse files
committed
feat: reload options page when client app is installed
1 parent cb4811e commit 290dfba

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/background/main.js

+10
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,8 @@ async function processMessage(request, sender) {
899899
return getBrowser();
900900
} else if (request.id === 'optionChange') {
901901
await onOptionChange();
902+
} else if (request.id === 'clientAppInstall') {
903+
await onClientAppInstall();
902904
}
903905
}
904906

@@ -908,6 +910,14 @@ function onMessage(request, sender, sendResponse) {
908910
return processMessageResponse(response, sendResponse);
909911
}
910912

913+
async function onClientAppInstall() {
914+
await storage.set({simulateUserInput: true});
915+
916+
await browser.runtime
917+
.sendMessage({id: 'reloadOptionsPage'})
918+
.catch(() => null);
919+
}
920+
911921
async function onOptionChange() {
912922
await setChallengeLocale();
913923
}

src/options/App.vue

+8
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ export default {
360360
getText,
361361
362362
setup: async function () {
363+
browser.runtime.onMessage.addListener(this.onMessage);
364+
363365
const options = await storage.get(optionKeys);
364366
365367
for (const option of Object.keys(this.options)) {
@@ -388,6 +390,12 @@ export default {
388390
this.dataLoaded = true;
389391
},
390392
393+
onMessage: function (request, sender) {
394+
if (request.id === 'reloadOptionsPage') {
395+
self.location.reload();
396+
}
397+
},
398+
391399
verifyClientApp: async function () {
392400
try {
393401
await pingClientApp();

src/setup/App.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
<script>
6666
import {App, Button, TextField} from 'vueton';
6767
68-
import storage from 'storage/storage';
6968
import {pingClientApp} from 'utils/app';
7069
import {getText} from 'utils/common';
7170
@@ -139,6 +138,8 @@ export default {
139138
method: 'POST',
140139
body: data
141140
});
141+
142+
await browser.runtime.sendMessage({id: 'clientAppInstall'});
142143
}
143144
},
144145
@@ -179,7 +180,6 @@ export default {
179180
180181
if (rsp.status === 200) {
181182
await pingClientApp();
182-
await storage.set({simulateUserInput: true});
183183
184184
this.isInstallSuccess = true;
185185
} else {

0 commit comments

Comments
 (0)