summaryrefslogtreecommitdiff
path: root/source/background.ts
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2023-07-08 20:54:43 +0200
committerGravatar GitHub <noreply@github.com> 2023-07-08 20:54:43 +0200
commitc864a20b57bb433aaf3952f88d83c9fc481ae6ff (patch)
tree60cc22a87e476f1552a7638f6c11996864ca0e8d /source/background.ts
parentd1b4fce11e9e51240325cbc67e39abe38db35dd2 (diff)
downloadrefined-github-23.7.8.tar.gz
refined-github-23.7.8.tar.zst
refined-github-23.7.8.zip
Update dependencies (#6766)23.7.8
Diffstat (limited to 'source/background.ts')
-rw-r--r--source/background.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/background.ts b/source/background.ts
index 209f722e..d2d1ef29 100644
--- a/source/background.ts
+++ b/source/background.ts
@@ -15,7 +15,7 @@ import {doesBrowserActionOpenOptions} from './helpers/feature-utils.js';
addDomainPermissionToggle();
const messageHandlers = {
- openUrls(urls: string[], {tab}: Runtime.MessageSender) {
+ async openUrls(urls: string[], {tab}: Runtime.MessageSender) {
for (const [i, url] of urls.entries()) {
void browser.tabs.create({
url,
@@ -24,7 +24,7 @@ const messageHandlers = {
});
}
},
- closeTab(_: any, {tab}: Runtime.MessageSender) {
+ async closeTab(_: any, {tab}: Runtime.MessageSender) {
void browser.tabs.remove(tab!.id!);
},
async fetch(url: string) {
@@ -35,12 +35,13 @@ const messageHandlers = {
const response = await fetch(url);
return response.json();
},
- openOptionsPage() {
- void browser.runtime.openOptionsPage();
+ async openOptionsPage() {
+ return browser.runtime.openOptionsPage();
},
-};
+ // They must return a promise to mark the message as handled
+} satisfies Record<string, (...arguments_: any[]) => Promise<any>>;
-browser.runtime.onMessage.addListener((message: typeof messageHandlers, sender) => {
+browser.runtime.onMessage.addListener((message: typeof messageHandlers, sender): Promise<unknown> | void => {
for (const id of objectKeys(message)) {
if (id in messageHandlers) {
return messageHandlers[id](message[id], sender);