mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-01-03 10:31:54 +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]);
|
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;
|
settingDefinition.hideAble = false;
|
||||||
}
|
}
|
||||||
@ -132,6 +140,14 @@
|
|||||||
listener(value[name]);
|
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){
|
function createSetter(settingDefinition){
|
||||||
if (settingDefinition.dynamic){
|
if (settingDefinition.dynamic){
|
||||||
@ -173,7 +186,7 @@
|
|||||||
else {
|
else {
|
||||||
const name = settingDefinition.name;
|
const name = settingDefinition.name;
|
||||||
let reset = function(){
|
let reset = function(){
|
||||||
settings[name] = settingDefinition.defaultValue;
|
settings[name] = getDefaultValue(settingDefinition);
|
||||||
browser.storage.local.remove(name);
|
browser.storage.local.remove(name);
|
||||||
};
|
};
|
||||||
if (settingDefinition.urlSpecific){
|
if (settingDefinition.urlSpecific){
|
||||||
@ -220,7 +233,7 @@
|
|||||||
if (typeof settingDefinition.defaultValue === "function"){
|
if (typeof settingDefinition.defaultValue === "function"){
|
||||||
settingDefinition.defaultValue = settingDefinition.defaultValue();
|
settingDefinition.defaultValue = settingDefinition.defaultValue();
|
||||||
}
|
}
|
||||||
settings[name] = settingDefinition.defaultValue;
|
settings[name] = getDefaultValue(settingDefinition);
|
||||||
eventHandler[name] = {};
|
eventHandler[name] = {};
|
||||||
|
|
||||||
settingDefinition.on = function on(callback, url){
|
settingDefinition.on = function on(callback, url){
|
||||||
@ -320,7 +333,7 @@
|
|||||||
if (settingDefinition){
|
if (settingDefinition){
|
||||||
var oldValue = settings[name];
|
var oldValue = settings[name];
|
||||||
if (newValue === resetSymbol){
|
if (newValue === resetSymbol){
|
||||||
newValue = settingDefinition.defaultValue;
|
newValue = getDefaultValue(settingDefinition);
|
||||||
}
|
}
|
||||||
settings[name] = newValue;
|
settings[name] = newValue;
|
||||||
((eventHandler[name] || {})[defaultSymbol] || []).forEach(function(callback){
|
((eventHandler[name] || {})[defaultSymbol] || []).forEach(function(callback){
|
||||||
@ -448,7 +461,7 @@
|
|||||||
scope.startupReset = function(){
|
scope.startupReset = function(){
|
||||||
scope.forEach(function(definition){
|
scope.forEach(function(definition){
|
||||||
if (definition.resetOnStartup){
|
if (definition.resetOnStartup){
|
||||||
definition.set(definition.defaultValue);
|
definition.set(getDefaultValue(definition));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@ Version 0.5.8:
|
|||||||
-
|
-
|
||||||
|
|
||||||
fixes:
|
fixes:
|
||||||
-
|
- after reset the hidden settings and expanded views were not reset
|
||||||
|
|
||||||
known issues:
|
known issues:
|
||||||
- if a data URL is blocked the page action button does not appear
|
- if a data URL is blocked the page action button does not appear
|
||||||
|
Loading…
x
Reference in New Issue
Block a user