1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-05-29 09:28:06 +02:00

Return storage promise from settings.set().

This commit is contained in:
kkapsner 2018-07-17 12:54:10 +02:00
parent 1f5f5bccc4
commit 9753681651
2 changed files with 11 additions and 6 deletions

View File

@ -68,6 +68,7 @@
value = settings[type + "List"];
}
lists[type] = getDomainRegExpList(value);
return lists[type];
}
Object.keys(lists).forEach(function(type){
settings.on(type + "List", function({newValue}){
@ -107,8 +108,10 @@
return lists[type];
};
scope.appendTo = function appendToList(type, entry){
settings[type + "List"] += (settings[type + "List"]? ",": "") + entry;
updateList(type);
var oldValue = settings[type + "List"];
return settings.set(type + "List", oldValue + (oldValue? ",": "") + entry).then(function(){
return updateList(type);
});
};
scope.update = updateList;
scope.updateAll = function updateAllLists(){

View File

@ -144,11 +144,13 @@
if (!settingDefinition.transient){
var storeObject = {};
storeObject[name] = newValue;
browser.storage.local.set(storeObject).then(function(){
var promise = browser.storage.local.set(storeObject);
promise.then(function(){
logging.verbose("New value stored for %s:", name, newValue);
}, function(err){
logging.warning("Unable to store new value for %s:", name, newValue, err);
});
return promise;
}
else {
logging.warning("Transient setting %s cannot be stored.", name);
@ -171,10 +173,10 @@
matching = [newEntry];
}
matching[0][settingDefinition.name] = newValue;
urlContainer.set(urlContainerValue);
return urlContainer.set(urlContainerValue);
}
else {
storeValue(newValue);
return storeValue(newValue);
}
}
else{
@ -186,7 +188,7 @@
return function setValue(newValue){
logging.verbose("New value for %s:", name, newValue);
if (isValid(newValue)){
storeValue(newValue);
return storeValue(newValue);
}
else{
logging.warning("Invalid value for %s:", name, newValue);