Skip to content

Commit

Permalink
Revert 09b3695 (re. browser.alarms)
Browse files Browse the repository at this point in the history
Relates issue:
- uBlockOrigin/uBlock-issues#2591

THe issue was simply that I had forgotten to add the `alarms`
permission to the manifest.
  • Loading branch information
gorhill committed Apr 11, 2023
1 parent 6f3b5df commit 8083e06
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 39 deletions.
39 changes: 0 additions & 39 deletions platform/common/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,45 +95,6 @@ vAPI.storage = webext.storage.local;
/******************************************************************************/
/******************************************************************************/

// https://github.com/uBlockOrigin/uBlock-issues/issues/2591
// Report of alarms API not being supported on Thunderbird
if ( browser.alarms === undefined ) {
browser.alarms = {
alarmsMap: new Map(),
listenerSet: new Set(),
create(name, delayInfo) {
let alarm = this.alarmsMap.get(name);
if ( alarm !== undefined ) {
alarm.off();
} else {
alarm = vAPI.defer.create(( ) => {
this.alarmsMap.delete(name);
for ( const listener of this.listenerSet ) {
listener({ name });
}
});
}
this.alarmsMap.set(name, alarm);
alarm.on({ min: delayInfo.delayInMinutes });
},
clear(name) {
const alarm = this.alarmsMap.get(name);
if ( alarm === undefined ) { return; }
alarm.off();
this.alarmsMap.delete(name);
},
get: function(name, callback) {
callback(this.alarmsMap.has(name) && { name } || undefined);
},
onAlarm: {
addListener(callback) {
browser.alarms.listenerSet.add(callback);
},
},
};
}


vAPI.alarms = {
create(callback) {
this.uniqueIdGenerator += 1;
Expand Down
1 change: 1 addition & 0 deletions platform/thunderbird/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"open_in_tab": true
},
"permissions": [
"alarms",
"privacy",
"storage",
"tabs",
Expand Down

0 comments on commit 8083e06

Please sign in to comment.