add missing 'alarm' permission

This commit is contained in:
Sebastian 2022-04-11 15:41:01 -03:00
parent c3c0f3bfbb
commit df81496b57
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
2 changed files with 13 additions and 4 deletions

View File

@ -13,7 +13,8 @@
"permissions": [
"unlimitedStorage",
"activeTab",
"scripting"
"scripting",
"alarms"
],
"optional_permissions": [
"webRequest"

View File

@ -45,8 +45,12 @@ export class ServiceWorkerTimerAPI implements TimerAPI {
const seconds = delayMs / 1000;
const periodInMinutes = Math.round(seconds < 61 ? 1 : seconds / 60);
logger.trace(`creating a alarm every ${periodInMinutes} ${delayMs}`)
chrome.alarms.create("wallet-worker", { periodInMinutes })
chrome.alarms.onAlarm.addListener(callback)
chrome.alarms.onAlarm.addListener((a) => {
logger.trace(`alarm called, every: ${a.name}`)
callback()
})
return new AlarmHandle();
}
@ -58,8 +62,12 @@ export class ServiceWorkerTimerAPI implements TimerAPI {
const seconds = delayMs / 1000;
const delayInMinutes = Math.round(seconds < 61 ? 1 : seconds / 60);
logger.trace(`creating a alarm after ${delayInMinutes} ${delayMs}`)
chrome.alarms.create("wallet-worker", { delayInMinutes })
chrome.alarms.onAlarm.addListener(callback)
chrome.alarms.onAlarm.addListener((a) => {
logger.trace(`alarm called, after: ${a.name}`)
callback();
})
return new AlarmHandle();
}