fix(background): fix background script init
This commit is contained in:
parent
dd95d5a0ac
commit
d97dc9da87
|
@ -2,6 +2,8 @@ import { REFRESH_TIMEOUT, HOMEPAGE, API_URLS, BADGE_COLORS } from './config.js';
|
||||||
// [INJECT-BROWSER-POLYFILL]
|
// [INJECT-BROWSER-POLYFILL]
|
||||||
|
|
||||||
browser.runtime.onInstalled.addListener(async (details) => {
|
browser.runtime.onInstalled.addListener(async (details) => {
|
||||||
|
init();
|
||||||
|
|
||||||
if (details.reason === 'install') {
|
if (details.reason === 'install') {
|
||||||
await browser.tabs.create({
|
await browser.tabs.create({
|
||||||
url: HOMEPAGE,
|
url: HOMEPAGE,
|
||||||
|
@ -9,6 +11,10 @@ browser.runtime.onInstalled.addListener(async (details) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
browser.runtime.onStartup.addListener(async () => {
|
||||||
|
init();
|
||||||
|
});
|
||||||
|
|
||||||
browser.alarms.onAlarm.addListener((alarm) => {
|
browser.alarms.onAlarm.addListener((alarm) => {
|
||||||
if (alarm.name === 'fetchData') {
|
if (alarm.name === 'fetchData') {
|
||||||
fetchNewData();
|
fetchNewData();
|
||||||
|
@ -107,5 +113,3 @@ function init() {
|
||||||
periodInMinutes: REFRESH_TIMEOUT,
|
periodInMinutes: REFRESH_TIMEOUT,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
Loading…
Reference in a new issue