From 9c6acae0cf233715e53d80cb863fa3e274c1e2e2 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 6 May 2020 19:38:02 +0300 Subject: [PATCH] Use boolean values if value equals 'true' or 'false' --- src/store/modules/normalizers.js | 9 +++++++++ src/views/settings/components/Inputs.vue | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 6eecebca..c146d60e 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -1,5 +1,14 @@ import _ from 'lodash' +export const getBooleanValue = value => { + if (value === 'true') { + return true + } else if (value === 'false') { + return false + } + return value +} + export const checkPartialUpdate = (settings, updatedSettings, description) => { return Object.keys(updatedSettings).reduce((acc, group) => { acc[group] = Object.keys(updatedSettings[group]).reduce((acc, key) => { diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index c0d62c6d..a756037b 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -132,7 +132,7 @@ import { RateLimitInput, RegInvitesInput, SelectInputWithReducedLabels } from './inputComponents' -import { processNested } from '@/store/modules/normalizers' +import { getBooleanValue, processNested } from '@/store/modules/normalizers' import _ from 'lodash' import marked from 'marked' @@ -332,9 +332,10 @@ export default { ) }, update(value, group, key, parents, input, type, nested) { + const updatedValue = getBooleanValue(value) nested - ? this.processNestedData(value, group, key, parents) - : this.updateSetting(value, group, key, input, type) + ? this.processNestedData(updatedValue, group, key, parents) + : this.updateSetting(updatedValue, group, key, input, type) }, updateSetting(value, group, key, input, type) { this.$store.dispatch('UpdateSettings', { group, key, input, value, type })