mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-30 23:38:47 +01:00
after reset the hidden settings and expanded views were not reset
Fixes #314
This commit is contained in:
parent
3133abf4f7
commit
53cdf8347e
@ -99,6 +99,14 @@
|
||||
listener(value[name]);
|
||||
});
|
||||
});
|
||||
const oldValue = event.oldValue;
|
||||
Object.keys(oldValue).filter(function(name){
|
||||
return !value.hasOwnProperty(name);
|
||||
}).forEach(function(name){
|
||||
(changeListeners[name] || []).forEach(function(listener){
|
||||
listener(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
settingDefinition.hideAble = false;
|
||||
}
|
||||
@ -132,6 +140,14 @@
|
||||
listener(value[name]);
|
||||
});
|
||||
});
|
||||
const oldValue = event.oldValue;
|
||||
Object.keys(oldValue).filter(function(name){
|
||||
return !value.hasOwnProperty(name);
|
||||
}).forEach(function(name){
|
||||
(changeListeners[name] || []).forEach(function(listener){
|
||||
listener(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -89,6 +89,19 @@
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultValue(settingDefinition){
|
||||
let defaultValue = settingDefinition.defaultValue;
|
||||
if ((typeof defaultValue) === "object"){
|
||||
if (Array.isArray(defaultValue)){
|
||||
return defaultValue.slice();
|
||||
}
|
||||
else {
|
||||
return Object.create(defaultValue);
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
function createSetter(settingDefinition){
|
||||
if (settingDefinition.dynamic){
|
||||
@ -173,7 +186,7 @@
|
||||
else {
|
||||
const name = settingDefinition.name;
|
||||
let reset = function(){
|
||||
settings[name] = settingDefinition.defaultValue;
|
||||
settings[name] = getDefaultValue(settingDefinition);
|
||||
browser.storage.local.remove(name);
|
||||
};
|
||||
if (settingDefinition.urlSpecific){
|
||||
@ -220,7 +233,7 @@
|
||||
if (typeof settingDefinition.defaultValue === "function"){
|
||||
settingDefinition.defaultValue = settingDefinition.defaultValue();
|
||||
}
|
||||
settings[name] = settingDefinition.defaultValue;
|
||||
settings[name] = getDefaultValue(settingDefinition);
|
||||
eventHandler[name] = {};
|
||||
|
||||
settingDefinition.on = function on(callback, url){
|
||||
@ -320,7 +333,7 @@
|
||||
if (settingDefinition){
|
||||
var oldValue = settings[name];
|
||||
if (newValue === resetSymbol){
|
||||
newValue = settingDefinition.defaultValue;
|
||||
newValue = getDefaultValue(settingDefinition);
|
||||
}
|
||||
settings[name] = newValue;
|
||||
((eventHandler[name] || {})[defaultSymbol] || []).forEach(function(callback){
|
||||
@ -448,7 +461,7 @@
|
||||
scope.startupReset = function(){
|
||||
scope.forEach(function(definition){
|
||||
if (definition.resetOnStartup){
|
||||
definition.set(definition.defaultValue);
|
||||
definition.set(getDefaultValue(definition));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -6,7 +6,7 @@ Version 0.5.8:
|
||||
-
|
||||
|
||||
fixes:
|
||||
-
|
||||
- after reset the hidden settings and expanded views were not reset
|
||||
|
||||
known issues:
|
||||
- if a data URL is blocked the page action button does not appear
|
||||
|
Loading…
x
Reference in New Issue
Block a user