Skip to content
Snippets Groups Projects
Commit 13aba7ea authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Fetch new data after removing a setting instead of updating it

parent ff137f41
No related branches found
No related tags found
1 merge request!77Ability to remove settings from db
......@@ -245,8 +245,6 @@ const wrapValues = (settings, currentState) => {
} else if (setting === ':ip') {
const ip = value.split('.').map(s => parseInt(s, 10))
return { 'tuple': [setting, { 'tuple': ip }] }
} else if (setting === ':ssl_options') {
return { 'tuple': [setting, wrapValues(value, currentState)] }
} else if (setting === ':args') {
const index = value.findIndex(el => el === 'implode')
const updatedArray = value.slice()
......
......@@ -51,18 +51,6 @@ const settings = {
: { [key]: { ...state.updatedSettings[group][key], ...{ [input]: [type, value] }}}
state.updatedSettings[group] = { ...state.updatedSettings[group], ...updatedSetting }
},
UPDATE_SETTINGS_AFTER_REMOVAL: (state, { configs, response }) => {
if (!response) {
const { [configs[0].key]: value, ...updatedSettings } = state.settings[configs[0].group]
state.settings[configs[0].group] = updatedSettings
} else {
const { group, key, value } = response
const parsedValue = valueHasTuples(key, value)
? { value: parseNonTuples(key, value) }
: parseTuples(value, key)
state.settings[group] = { ...state.settings[group], [key]: parsedValue }
}
},
UPDATE_STATE: (state, { group, key, input, value }) => {
const updatedState = key === 'Pleroma.Emails.Mailer' && input === ':adapter'
? { [key]: { [input]: value }}
......@@ -81,9 +69,10 @@ const settings = {
commit('SET_LOADING', false)
},
async RemoveSetting({ commit, getters }, configs) {
const response = await removeSettings(configs, getters.authHost, getters.token)
await removeSettings(configs, getters.authHost, getters.token)
const response = await fetchSettings(getters.authHost, getters.token)
const { group, key, subkeys } = configs[0]
commit('UPDATE_SETTINGS_AFTER_REMOVAL', { response: response.data.configs[0], configs })
commit('SET_SETTINGS', response.data.configs)
commit('REMOVE_SETTING_FROM_UPDATED', { group, key, subkeys: subkeys || [] })
},
async SubmitChanges({ getters, commit, state }) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment