From 59e9802337b612275982ed5c305e789ea4aaf69f Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 6 Dec 2019 17:30:17 +0900 Subject: [PATCH] Wrap values with type map --- src/store/modules/normalizers.js | 8 +++++++- src/store/modules/settings.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 18d886d7..f2aaa9b5 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -3,7 +3,7 @@ const nonAtomsObjects = ['match_actor', ':match_actor'] const objects = ['digest', 'pleroma_fe', 'masto_fe', 'poll_limits', 'styling'] const objectParents = ['mascots'] -const groupWithoutKey = settings => settings.noKey ? settings.noKey[1] : false +const groupWithoutKey = settings => settings._value ? settings._value[1] : false // REFACTOR export const parseTuples = (tuples, key) => { @@ -83,6 +83,12 @@ const wrapValues = settings => { return { 'tuple': [setting, wrapValues(value)] } } else if (type === 'atom') { return { 'tuple': [setting, `:${value}`] } + } else if (type === 'map') { + const objectValue = Object.keys(value).reduce((acc, key) => { + acc[key] = value[key][1] + return acc + }, {}) + return { 'tuple': [setting, objectValue] } } else if (setting === ':ip') { const ip = value.split('.').map(s => parseInt(s, 10)) return { 'tuple': [setting, { 'tuple': ip }] } diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 8e6e65c0..a3216331 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -85,7 +85,7 @@ const settings = { UpdateSettings({ commit }, { group, key, input, value, type }) { key ? commit('UPDATE_SETTINGS', { group, key, input, value, type }) - : commit('UPDATE_SETTINGS', { group, key: input, input: 'noKey', value, type }) + : commit('UPDATE_SETTINGS', { group, key: input, input: '_value', value, type }) }, UpdateState({ commit }, { group, key, input, value }) { key