From 1c7a7cc906e6326cd46235cb2e1b62b69a441e43 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 3 Jan 2020 13:31:07 +0700 Subject: [PATCH] Fix processing nested data for dispatch setting --- src/store/modules/normalizers.js | 10 ++++++---- src/views/settings/components/Inputs.vue | 4 ++-- src/views/settings/components/Setting.vue | 2 +- src/views/settings/index.vue | 14 ++++++++------ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index e79fb043..984062ff 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -134,18 +134,18 @@ export const partialUpdate = (group, key) => { export const processNested = (valueForState, valueForUpdatedSettings, group, parentKey, parents, settings, updatedSettings) => { const [{ key, type }, ...otherParents] = parents - const path = [group, parentKey, ...parents.reverse().map(parent => parent.key)] + const path = [group, parentKey, ...parents.reverse().map(parent => parent.key).slice(0, -1)] const updatedValueForState = valueExists(settings, path) ? { ...getCurrentValue(settings[group][parentKey], parents.map(el => el.key).slice(0, -1)), ...{ [key]: valueForState }} : { [key]: valueForState } const updatedValueForUpdatedSettings = valueExists(updatedSettings, path) - ? { ...getCurrentValue(settings[group][parentKey], parents.map(el => el.key).slice(0, -1)), + ? { ...getCurrentValue(updatedSettings[group][parentKey], parents.map(el => el.key).slice(0, -1))[1], ...{ [key]: [type, valueForUpdatedSettings] }} : { [key]: [type, valueForUpdatedSettings] } - // if (group === ':mime' && key === ':types') { + // if (group === ':mime' && key === ':types') { // updatedValueForState = { ...settings[group][key].value, ...updatedValueForState } // updatedValueForUpdatedSettings = { // ...Object.keys(settings[group][key].value) @@ -197,8 +197,10 @@ const wrapValues = (settings, currentState) => { return { 'tuple': [setting, wrapValues(value, currentState)] } } else if (type === 'atom' && value.length > 0) { return { 'tuple': [setting, `:${value}`] } - } else if (type.includes('tuple') && (type.includes('string') || type.includes('list') || type.includes('atom'))) { + } else if (type.includes('tuple') && (type.includes('string') || type.includes('atom'))) { return { 'tuple': [setting, { 'tuple': value }] } + } else if (type.includes('tuple') && type.includes('list')) { + return { 'tuple': [setting, value] } } else if (type === 'map') { const mapValue = Object.keys(value).reduce((acc, key) => { acc[key] = setting === ':match_actor' ? value[key] : value[key][1] diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index fbe3a92b..c707b859 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -59,7 +59,7 @@
diff --git a/src/views/settings/index.vue b/src/views/settings/index.vue index 14f34e40..91c73493 100644 --- a/src/views/settings/index.vue +++ b/src/views/settings/index.vue @@ -47,6 +47,9 @@ + @@ -59,18 +62,17 @@ + + + - + -->