diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index e647a4a7..ed0d04b8 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -57,10 +57,18 @@ export const parseNonTuples = (key, value) => { // REFACTOR export const parseTuples = (tuples, key) => { return tuples.reduce((accum, item) => { - if (key === ':rate_limit') { - accum[item.tuple[0]] = Array.isArray(item.tuple[1]) - ? item.tuple[1].map(el => el.tuple) - : item.tuple[1].tuple + if (key === ':rate_limit' || + (key === 'Pleroma.Web.Endpoint.MetricsExporter' && item.tuple[0] === ':auth')) { + const getValue = () => { + if (typeof item.tuple[1] === 'boolean') { + return item.tuple[1] + } else if (Array.isArray(item.tuple[1])) { + return item.tuple[1].map(el => el.tuple) + } else { + return item.tuple[1].tuple + } + } + accum[item.tuple[0]] = getValue() } 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)}` }}] @@ -237,8 +245,9 @@ const wrapValues = (settings, currentState) => { return { 'tuple': [setting, wrapValues(value, currentState)] } } else if (prependWithСolon(type, value)) { return { 'tuple': [setting, `:${value}`] } - } else if (type.includes('tuple') && (type.includes('string') || type.includes('atom'))) { - return typeof value === 'string' + } else if (type.includes('tuple') && + (type.includes('string') || type.includes('atom') || type.includes('boolean'))) { + return typeof value === 'string' || typeof value === 'boolean' ? { 'tuple': [setting, value] } : { 'tuple': [setting, { 'tuple': value }] } } else if (type === 'reversed_tuple') { diff --git a/src/views/settings/components/inputComponents/BooleanCombinedInput.vue b/src/views/settings/components/inputComponents/BooleanCombinedInput.vue index 7f7e9d90..b7e90402 100644 --- a/src/views/settings/components/inputComponents/BooleanCombinedInput.vue +++ b/src/views/settings/components/inputComponents/BooleanCombinedInput.vue @@ -1,28 +1,39 @@ @@ -50,24 +61,39 @@ export default { } }, computed: { - autoLinkerAtomValue() { + atomValue() { return this.data[this.setting.key] && this.data[this.setting.key][0] === ':' ? this.data[this.setting.key].substr(1) : this.data[this.setting.key] }, - autoLinkerBooleanValue() { + booleanValue() { const value = this.data[this.setting.key] - return typeof value === 'string' || typeof value === 'number' + return typeof value !== 'boolean' }, - autoLinkerIntegerValue() { + integerValue() { const value = this.data[this.setting.key] return value || 0 }, - autoLinkerStringValue() { + stringValue() { const value = this.data[this.setting.key] return value || '' + }, + tupleValue() { + const value = this.data[this.setting.key] + return value || ['', '', ''] } }, methods: { + processTupleTwoTypeValue(value, input, _index) { + if (value === false) { + this.updateSetting(value, this.settingGroup.group, this.settingGroup.key, input, this.setting.type) + } else if (value === true) { + this.updateSetting(['', '', ''], this.settingGroup.group, this.settingGroup.key, input, this.setting.type) + } else { + const data = [...this.tupleValue] + data[_index] = value + this.updateSetting(data, this.settingGroup.group, this.settingGroup.key, input, this.setting.type) + } + }, processTwoTypeValue(value, input) { if (value === true) { const data = input === ':truncate' ? 0 : '' diff --git a/src/views/settings/styles/main.scss b/src/views/settings/styles/main.scss index db55ac70..c55208ad 100644 --- a/src/views/settings/styles/main.scss +++ b/src/views/settings/styles/main.scss @@ -352,6 +352,15 @@ line-height: 20px; margin-right: 15px } + .tuple-input { + margin-right: 15px; + } + .tuple-input:last-child { + margin-right: 0; + } + .tuple-input-container { + display: flex; + } .upload-container { display: flex; align-items: baseline;