fix(background): fix background script init

This commit is contained in:
Thomas Rupprecht 2023-09-13 20:09:46 +02:00
parent dd95d5a0ac
commit d97dc9da87
1 changed files with 6 additions and 2 deletions

View File

@ -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();