added patch functions to actions/soapbox. edited features/configuration to support patchSoapbox method. Data not properly formattted yet.
This commit is contained in:
parent
b95e6a53eb
commit
58481d2e07
2 changed files with 42 additions and 2 deletions
|
@ -3,6 +3,10 @@ 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 function fetchSoapboxConfig() {
|
||||
return (dispatch, getState) => {
|
||||
api(getState).get('/api/pleroma/frontend_configurations').then(response => {
|
||||
|
@ -42,3 +46,39 @@ export function soapboxConfigFail(error) {
|
|||
skipAlert: true,
|
||||
};
|
||||
}
|
||||
|
||||
export function patchSoapbox(params) {
|
||||
console.log(JSON.stringify(params));
|
||||
return (dispatch, getState) => {
|
||||
dispatch(patchSoapboxRequest());
|
||||
return api(getState)
|
||||
.patch('/api/pleroma/admin/config', params)
|
||||
.then(response => {
|
||||
dispatch(patchSoapboxSuccess(response.data));
|
||||
}).catch(error => {
|
||||
dispatch(patchSoapboxFail(error));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function patchSoapboxRequest() {
|
||||
return {
|
||||
type: SOAPBOX_PATCH_REQUEST,
|
||||
};
|
||||
}
|
||||
|
||||
export function patchSoapboxSuccess(me) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: SOAPBOX_PATCH_SUCCESS,
|
||||
me,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function patchSoapboxFail(error) {
|
||||
return {
|
||||
type: SOAPBOX_PATCH_FAIL,
|
||||
error,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
Map as ImmutableMap,
|
||||
List as ImmutableList,
|
||||
} from 'immutable';
|
||||
import { patchMe } from 'soapbox/actions/me';
|
||||
import { patchSoapbox } from 'soapbox/actions/soapbox';
|
||||
import { unescape } from 'lodash';
|
||||
|
||||
const MAX_FIELDS = 4; // TODO: Make this dynamic by the instance
|
||||
|
@ -119,7 +119,7 @@ class EditProfile extends ImmutablePureComponent {
|
|||
|
||||
handleSubmit = (event) => {
|
||||
const { dispatch } = this.props;
|
||||
dispatch(patchMe(this.getFormdata())).then(() => {
|
||||
dispatch(patchSoapbox(this.getFormdata())).then(() => {
|
||||
this.setState({ isLoading: false });
|
||||
}).catch((error) => {
|
||||
this.setState({ isLoading: false });
|
||||
|
|
Loading…
Reference in a new issue