From d97dc9da878010d976d09f57c34072976458b2a7 Mon Sep 17 00:00:00 2001 From: Thomas Rupprecht Date: Wed, 13 Sep 2023 20:09:46 +0200 Subject: [PATCH] fix(background): fix background script init --- src/background.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/background.js b/src/background.js index f9163e6..ac25b09 100644 --- a/src/background.js +++ b/src/background.js @@ -2,6 +2,8 @@ import { REFRESH_TIMEOUT, HOMEPAGE, API_URLS, BADGE_COLORS } from './config.js'; // [INJECT-BROWSER-POLYFILL] browser.runtime.onInstalled.addListener(async (details) => { + init(); + if (details.reason === 'install') { await browser.tabs.create({ url: HOMEPAGE, @@ -9,6 +11,10 @@ browser.runtime.onInstalled.addListener(async (details) => { } }); +browser.runtime.onStartup.addListener(async () => { + init(); +}); + browser.alarms.onAlarm.addListener((alarm) => { if (alarm.name === 'fetchData') { fetchNewData(); @@ -107,5 +113,3 @@ function init() { periodInMinutes: REFRESH_TIMEOUT, }); } - -init();