mirror of https://github.com/gorhill/uBlock.git
Forgot Chromium's `alarms` API is not promisified...
This commit is contained in:
parent
d1fe023281
commit
c2c80be897
|
@ -54,6 +54,15 @@ const promisify = function(thisArg, fnName) {
|
|||
};
|
||||
|
||||
const webext = {
|
||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/alarms
|
||||
alarms: {
|
||||
clear: promisifyNoFail(chrome.alarms, 'clear'),
|
||||
clearAll: promisifyNoFail(chrome.alarms, 'clearAll'),
|
||||
create: promisifyNoFail(chrome.alarms, 'create'),
|
||||
get: promisifyNoFail(chrome.alarms, 'get'),
|
||||
getAll: promisifyNoFail(chrome.alarms, 'getAll'),
|
||||
onAlarm: chrome.alarms.onAlarm,
|
||||
},
|
||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction
|
||||
browserAction: {
|
||||
setBadgeBackgroundColor: promisifyNoFail(chrome.browserAction, 'setBadgeBackgroundColor'),
|
||||
|
|
|
@ -1781,20 +1781,20 @@ vAPI.cloud = (( ) => {
|
|||
|
||||
vAPI.alarms = {
|
||||
create(...args) {
|
||||
browser.alarms.create(...args);
|
||||
webext.alarms.create(...args);
|
||||
},
|
||||
createIfNotPresent(name, ...args) {
|
||||
browser.alarms.get(name).then(details => {
|
||||
webext.alarms.get(name).then(details => {
|
||||
if ( details !== undefined ) { return; }
|
||||
browser.alarms.create(name, ...args);
|
||||
webext.alarms.create(name, ...args);
|
||||
});
|
||||
},
|
||||
async clear(...args) {
|
||||
return browser.alarms.clear(...args);
|
||||
return webext.alarms.clear(...args);
|
||||
},
|
||||
onAlarm: {
|
||||
addListener(...args) {
|
||||
browser.alarms.onAlarm.addListener(...args);
|
||||
webext.alarms.onAlarm.addListener(...args);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue