mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Switch to asych/await where useful
This commit is contained in:
parent
372ee755f7
commit
10413a89c3
11 changed files with 269 additions and 349 deletions
|
@ -163,16 +163,12 @@
|
|||
});
|
||||
};
|
||||
|
||||
settings.on("showNotifications", function({newValue}){
|
||||
settings.on("showNotifications", async function({newValue}){
|
||||
if (!newValue){
|
||||
logging.message("notifications were disabled -> hide all page actions");
|
||||
browser.tabs.query({}).then(function(tabs){
|
||||
tabs.forEach(function(tab){
|
||||
browser.pageAction.hide(tab.id);
|
||||
});
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Unable to get browser tabs:", error);
|
||||
const tabs = await browser.tabs.query({});
|
||||
tabs.forEach(function(tab){
|
||||
browser.pageAction.hide(tab.id);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -180,20 +176,16 @@
|
|||
browser.tabs.onRemoved.addListener(function(tabId){
|
||||
tabsData.delete(tabId);
|
||||
});
|
||||
settings.on("displayBadge", function({newValue}){
|
||||
settings.on("displayBadge", async function({newValue}){
|
||||
if (!newValue){
|
||||
logging.message("badge was disabled -> hide all badges");
|
||||
if (browser.browserAction.setBadgeText){
|
||||
browser.tabs.query({}).then(function(tabs){
|
||||
tabs.forEach(function(tab){
|
||||
browser.browserAction.setBadgeText({
|
||||
tabId: tab.id,
|
||||
text: ""
|
||||
});
|
||||
const tabs = await browser.tabs.query({});
|
||||
tabs.forEach(function(tab){
|
||||
browser.browserAction.setBadgeText({
|
||||
tabId: tab.id,
|
||||
text: ""
|
||||
});
|
||||
return;
|
||||
}).catch(function(error){
|
||||
logging.warning("Unable to get browser tabs:", error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue