1
0
Fork 0
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:
kkapsner 2019-12-28 23:23:55 +01:00
parent 372ee755f7
commit 10413a89c3
11 changed files with 269 additions and 349 deletions

View file

@ -129,24 +129,24 @@
}
return true;
};
const storeValue = function storeValue(newValue){
const storeValue = async function storeValue(newValue){
logging.verbose("Trying to store new value for %s", name, newValue);
settings[name] = newValue;
if (!settingDefinition.transient){
const storeObject = {};
storeObject[name] = newValue;
const promise = browser.storage.local.set(storeObject);
promise.then(function(){
try {
await browser.storage.local.set(storeObject);
logging.verbose("New value stored for %s:", name, newValue);
return;
}).catch(function(error){
}
catch (error){
logging.error("Unable to store new value for %s:", name, newValue, error);
});
return promise;
throw error;
}
}
else {
logging.warning("Transient setting %s cannot be stored.", name);
return Promise.reject("Transient setting " + name + " cannot be stored.");
throw "Transient setting " + name + " cannot be stored.";
}
};