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"];
|
value = settings[type + "List"];
|
||||||
}
|
}
|
||||||
lists[type] = getDomainRegExpList(value);
|
lists[type] = getDomainRegExpList(value);
|
||||||
|
return lists[type];
|
||||||
}
|
}
|
||||||
Object.keys(lists).forEach(function(type){
|
Object.keys(lists).forEach(function(type){
|
||||||
settings.on(type + "List", function({newValue}){
|
settings.on(type + "List", function({newValue}){
|
||||||
@ -107,8 +108,10 @@
|
|||||||
return lists[type];
|
return lists[type];
|
||||||
};
|
};
|
||||||
scope.appendTo = function appendToList(type, entry){
|
scope.appendTo = function appendToList(type, entry){
|
||||||
settings[type + "List"] += (settings[type + "List"]? ",": "") + entry;
|
var oldValue = settings[type + "List"];
|
||||||
updateList(type);
|
return settings.set(type + "List", oldValue + (oldValue? ",": "") + entry).then(function(){
|
||||||
|
return updateList(type);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
scope.update = updateList;
|
scope.update = updateList;
|
||||||
scope.updateAll = function updateAllLists(){
|
scope.updateAll = function updateAllLists(){
|
||||||
|
@ -144,11 +144,13 @@
|
|||||||
if (!settingDefinition.transient){
|
if (!settingDefinition.transient){
|
||||||
var storeObject = {};
|
var storeObject = {};
|
||||||
storeObject[name] = newValue;
|
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);
|
logging.verbose("New value stored for %s:", name, newValue);
|
||||||
}, function(err){
|
}, function(err){
|
||||||
logging.warning("Unable to store new value for %s:", name, newValue, err);
|
logging.warning("Unable to store new value for %s:", name, newValue, err);
|
||||||
});
|
});
|
||||||
|
return promise;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logging.warning("Transient setting %s cannot be stored.", name);
|
logging.warning("Transient setting %s cannot be stored.", name);
|
||||||
@ -171,10 +173,10 @@
|
|||||||
matching = [newEntry];
|
matching = [newEntry];
|
||||||
}
|
}
|
||||||
matching[0][settingDefinition.name] = newValue;
|
matching[0][settingDefinition.name] = newValue;
|
||||||
urlContainer.set(urlContainerValue);
|
return urlContainer.set(urlContainerValue);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
storeValue(newValue);
|
return storeValue(newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -186,7 +188,7 @@
|
|||||||
return function setValue(newValue){
|
return function setValue(newValue){
|
||||||
logging.verbose("New value for %s:", name, newValue);
|
logging.verbose("New value for %s:", name, newValue);
|
||||||
if (isValid(newValue)){
|
if (isValid(newValue)){
|
||||||
storeValue(newValue);
|
return storeValue(newValue);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
logging.warning("Invalid value for %s:", name, newValue);
|
logging.warning("Invalid value for %s:", name, newValue);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user