mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +01:00
Return storage promise from settings.set().
This commit is contained in:
parent
1f5f5bccc4
commit
9753681651
@ -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(){
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user