diff --git a/app/soapbox/actions/soapbox.js b/app/soapbox/actions/soapbox.js index 91038cca0..71396aa0a 100644 --- a/app/soapbox/actions/soapbox.js +++ b/app/soapbox/actions/soapbox.js @@ -3,9 +3,9 @@ import api from '../api'; export const SOAPBOX_CONFIG_REQUEST_SUCCESS = 'SOAPBOX_CONFIG_REQUEST_SUCCESS'; export const SOAPBOX_CONFIG_REQUEST_FAIL = 'SOAPBOX_CONFIG_REQUEST_FAIL'; -export const SOAPBOX_PATCH_REQUEST = 'SOAPBOX_PATCH_REQUEST'; -export const SOAPBOX_PATCH_SUCCESS = 'SOAPBOX_PATCH_SUCCESS'; -export const SOAPBOX_PATCH_FAIL = 'SOAPBOX_PATCH_FAIL'; +export const SOAPBOX_POST_REQUEST = 'SOAPBOX_POST_REQUEST'; +export const SOAPBOX_POST_SUCCESS = 'SOAPBOX_POST_REQUEST'; +export const SOAPBOX_POST_FAIL = 'SOAPBOX_POST_REQUEST'; export function fetchSoapboxConfig() { return (dispatch, getState) => { @@ -47,38 +47,35 @@ export function soapboxConfigFail(error) { }; } -export function patchSoapbox(params) { - console.log(params); +export function postSoapbox(params) { return (dispatch, getState) => { - dispatch(patchSoapboxRequest()); + dispatch(postSoapboxRequest()); return api(getState) - .patch('/api/pleroma/admin/config', params) + .post('/api/pleroma/admin/config', params) .then(response => { - dispatch(patchSoapboxSuccess(response.data)); + dispatch(postSoapboxSuccess(response.data)); }).catch(error => { - dispatch(patchSoapboxFail(error)); + dispatch(postSoapboxFail(error)); }); }; } -export function patchSoapboxRequest() { +export function postSoapboxRequest() { return { - type: SOAPBOX_PATCH_REQUEST, + type: SOAPBOX_POST_REQUEST, }; } -export function patchSoapboxSuccess(me) { - return (dispatch, getState) => { - dispatch({ - type: SOAPBOX_PATCH_SUCCESS, - me, - }); +export function postSoapboxSuccess(soapboxConfig) { + return { + type: SOAPBOX_POST_SUCCESS, + soapboxConfig, }; } -export function patchSoapboxFail(error) { +export function postSoapboxFail(error) { return { - type: SOAPBOX_PATCH_FAIL, + type: SOAPBOX_POST_FAIL, error, }; }; diff --git a/app/soapbox/features/configuration/index.js b/app/soapbox/features/configuration/index.js index 8a33eb1f3..d5371d8c3 100644 --- a/app/soapbox/features/configuration/index.js +++ b/app/soapbox/features/configuration/index.js @@ -17,7 +17,7 @@ import { Map as ImmutableMap, List as ImmutableList, } from 'immutable'; -import { patchSoapbox } from 'soapbox/actions/soapbox'; +import { postSoapbox } from 'soapbox/actions/soapbox'; const messages = defineMessages({ heading: { id: 'column.soapbox_settings', defaultMessage: 'Soapbox settings' }, @@ -164,7 +164,7 @@ class ConfigSoapbox extends ImmutablePureComponent { handleSubmit = (event) => { const { dispatch } = this.props; - dispatch(patchSoapbox(this.getParams())).then(() => { + dispatch(postSoapbox(this.getParams())).then(() => { this.setState({ isLoading: false }); }).catch((error) => { this.setState({ isLoading: false }); diff --git a/app/soapbox/reducers/soapbox.js b/app/soapbox/reducers/soapbox.js index 147bd6c49..a039accd5 100644 --- a/app/soapbox/reducers/soapbox.js +++ b/app/soapbox/reducers/soapbox.js @@ -1,6 +1,7 @@ import { SOAPBOX_CONFIG_REQUEST_SUCCESS, SOAPBOX_CONFIG_REQUEST_FAIL, + SOAPBOX_POST_SUCCESS, } from '../actions/soapbox'; import { Map as ImmutableMap, fromJS } from 'immutable'; @@ -16,6 +17,9 @@ export default function soapbox(state = initialState, action) { return defaultState.merge(ImmutableMap(fromJS(action.soapboxConfig))); case SOAPBOX_CONFIG_REQUEST_FAIL: return defaultState; + case SOAPBOX_POST_SUCCESS: + const soapbox = ImmutableMap(fromJS(action.soapboxConfig)).configs[0].value[0].tuple[1]; + return soapbox; default: return state; }