mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Conservative config delta logic
Avoid referring to the global state and consult oldValue to determine what settings have changed instead.
This commit is contained in:
parent
1cbf1d3f3f
commit
6528c69314
1 changed files with 7 additions and 7 deletions
|
@ -1541,10 +1541,10 @@ const parseConfigHelper = (pconf, parseobj) => {
|
|||
// TODO: BUG! Sync and local storage are merged at startup, but not by this thing.
|
||||
browser.storage.onChanged.addListener((changes, areaname) => {
|
||||
if (CONFIGNAME in changes) {
|
||||
const { newValue } = changes[CONFIGNAME]
|
||||
const old = USERCONFIG
|
||||
const { newValue, oldValue } = changes[CONFIGNAME]
|
||||
const old = oldValue || {}
|
||||
|
||||
function triggerChangeListeners(key, value = USERCONFIG[key]) {
|
||||
function triggerChangeListeners(key, value = newValue[key]) {
|
||||
const arr = changeListeners.get(key)
|
||||
if (arr) {
|
||||
const v = old[key] === undefined ? DEFAULTS[key] : old[key]
|
||||
|
@ -1554,10 +1554,10 @@ browser.storage.onChanged.addListener((changes, areaname) => {
|
|||
|
||||
if (newValue !== undefined) {
|
||||
// A key has been :unset if it exists in USERCONFIG and doesn't in changes and if its value in USERCONFIG is different from the one it has in default_config
|
||||
const unsetKeys = Object.keys(USERCONFIG).filter(
|
||||
const unsetKeys = Object.keys(old).filter(
|
||||
k =>
|
||||
newValue[k] === undefined &&
|
||||
JSON.stringify(USERCONFIG[k]) !==
|
||||
JSON.stringify(old[k]) !==
|
||||
JSON.stringify(DEFAULTS[k]),
|
||||
)
|
||||
|
||||
|
@ -1567,8 +1567,8 @@ browser.storage.onChanged.addListener((changes, areaname) => {
|
|||
).filter(
|
||||
k =>
|
||||
JSON.stringify(
|
||||
USERCONFIG[k] !== undefined
|
||||
? USERCONFIG[k]
|
||||
old[k] !== undefined
|
||||
? old[k]
|
||||
: DEFAULTS[k],
|
||||
) !== JSON.stringify(newValue[k]),
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue