diff options
| author | Henry Jameson <me@hjkos.com> | 2021-03-08 21:14:03 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2021-03-08 21:14:03 +0200 |
| commit | fada49768dcd12faae4f7a188bdd36ea60f8b0a8 (patch) | |
| tree | a0bb00830e54a70bb18a76a4b3e966886aff04d9 | |
| parent | 914b4eb5938f00284afff3c210dcafa94e48f510 (diff) | |
extra protection to not write what we don't know
| -rw-r--r-- | src/modules/config.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/modules/config.js b/src/modules/config.js index ec3b4c43..352adf20 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -111,7 +111,16 @@ const config = { }, actions: { loadSettings ({ dispatch }, data) { - Object.keys(this.state.config).forEach( + const knownKeys = new Set(Object.keys(this.state.config)) + const presentKeys = new Set(Object.keys(data)) + const intersection = new Set() + for (let elem of presentKeys) { + if (knownKeys.has(elem)) { + intersection.add(elem) + } + } + + Object.keys(intersection).forEach( name => dispatch('setOption', { name, value: data[name] }) ) }, |
