From 191199a41c92e3833039b0d8ec4f8cc8c7083783 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 4 Dec 2019 23:17:05 +0900 Subject: [PATCH] Parse and wrap atoms --- src/store/modules/normalizers.js | 4 +++- src/views/settings/components/Inputs.vue | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index f051b163..81c57c89 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -80,7 +80,9 @@ const wrapValues = settings => { return Object.keys(settings).map(setting => { const [type, value] = settings[setting] if (type === 'keyword') { - return { 'tuple': [setting, wrapValues(setting, value)] } + return { 'tuple': [setting, wrapValues(value)] } + } else if (type === 'atom') { + return { 'tuple': [setting, `:${value}`] } } else { return { 'tuple': [setting, value] } } diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 3fa248f2..280e4827 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -259,6 +259,8 @@ export default { } else if ((this.settingGroup.group === ':logger' && this.setting.key === ':backends') || this.setting.key === 'Pleroma.Web.Auth.Authenticator') { return this.data.value + } else if (this.setting.type === 'atom') { + return this.data[this.setting.key] && this.data[this.setting.key][0] === ':' ? this.data[this.setting.key].substr(1) : this.data[this.setting.key] } else { return this.data[this.setting.key] } @@ -303,6 +305,12 @@ export default { }, rewritePolicyValue() { return typeof this.data[this.setting.key] === 'string' ? [this.data[this.setting.key]] : this.data[this.setting.key] + }, + settings() { + return this.$store.state.settings.settings + }, + updatedSettings() { + return this.$store.state.settings.updatedSettings } }, methods: { @@ -408,9 +416,12 @@ export default { processAutoLinker(value, tab, inputName, childName) { }, processNestedData(value, group, key, parentInput, parentType, childInput, childType) { - const updatedValueForState = { ...this.$store.state.settings.settings[group][key][parentInput], ...{ [childInput]: value }} - const updatedValue = this.$store.state.settings.updatedSettings[group] - ? { ...this.$store.state.settings.updatedSettings[group][key][parentInput][1], ...{ [childInput]: [childType, value] }} + const valueExists = value => value[group] && value[group][key] && value[group][key][parentInput] + const updatedValueForState = valueExists(this.settings) + ? { ...this.settings[group][key][parentInput], ...{ [childInput]: value }} + : { [childInput]: value } + const updatedValue = valueExists(this.updatedSettings) + ? { ...this.updatedSettings[group][key][parentInput][1], ...{ [childInput]: [childType, value] }} : { [childInput]: [childType, value] } this.$store.dispatch('UpdateSettings', { group, key, input: parentInput, value: updatedValue, type: parentType }) this.$store.dispatch('UpdateState', { group, key, input: parentInput, value: updatedValueForState })