From 401c980e9972649d2c79d18081362851d5d13990 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sat, 14 Dec 2019 02:06:52 +0300 Subject: [PATCH] Fix mascots setting so it accepts array data --- src/store/modules/normalizers.js | 6 +- .../inputComponents/MascotsInput.vue | 60 ++++++++++++------- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index c9dbc850..43a56a06 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -10,8 +10,10 @@ export const parseTuples = (tuples, key) => { return tuples.reduce((accum, item) => { if (key === 'rate_limit') { accum[item.tuple[0]] = item.tuple[1] - } else if (key === ':mascots') { - accum[item.tuple[0]] = { ...item.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` } + } else if (item.tuple[0] === ':mascots') { + accum[item.tuple[0]] = item.tuple[1].reduce((acc, mascot) => { + return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] + }, []) } else if (item.tuple[0] === ':groups') { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] diff --git a/src/views/settings/components/inputComponents/MascotsInput.vue b/src/views/settings/components/inputComponents/MascotsInput.vue index 40b68500..6397a8e1 100644 --- a/src/views/settings/components/inputComponents/MascotsInput.vue +++ b/src/views/settings/components/inputComponents/MascotsInput.vue @@ -1,17 +1,17 @@