use globalThis instead of window to also work in service worker

This commit is contained in:
Thomas Rupprecht 2023-01-06 02:19:12 +01:00
parent f97b9a7538
commit 8202083710
1 changed files with 3 additions and 3 deletions

View File

@ -94,13 +94,13 @@ function startFetching() {
}); });
} }
window.addEventListener('offline', async () => { globalThis.addEventListener('offline', async () => {
browser.alarms.onAlarm.removeListener(handleAlarm); browser.alarms.onAlarm.removeListener(handleAlarm);
await browser.alarms.clear('fetchData'); await browser.alarms.clear('fetchData');
}); });
window.addEventListener('online', () => { globalThis.addEventListener('online', () => {
startFetching(); startFetching();
}); });
if (window.navigator.onLine) { if (globalThis.navigator.onLine) {
startFetching(); startFetching();
} }