patchMe(): use multipart/form-data only optionally
This commit is contained in:
parent
d6d4fd2b91
commit
9ce9a3f951
2 changed files with 8 additions and 8 deletions
|
@ -6,7 +6,7 @@ import api from '../api';
|
||||||
import { loadCredentials } from './auth';
|
import { loadCredentials } from './auth';
|
||||||
import { importFetchedAccount } from './importer';
|
import { importFetchedAccount } from './importer';
|
||||||
|
|
||||||
import type { AxiosError } from 'axios';
|
import type { AxiosError, AxiosRequestHeaders } from 'axios';
|
||||||
import type { AppDispatch, RootState } from 'soapbox/store';
|
import type { AppDispatch, RootState } from 'soapbox/store';
|
||||||
import type { APIEntity } from 'soapbox/types/entities';
|
import type { APIEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
@ -62,16 +62,16 @@ const persistAuthAccount = (account: APIEntity, params: Record<string, any>) =>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const patchMe = (params: Record<string, any>) =>
|
const patchMe = (params: Record<string, any>, isFormData = false) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
dispatch(patchMeRequest());
|
dispatch(patchMeRequest());
|
||||||
|
|
||||||
|
const headers: AxiosRequestHeaders = isFormData ? {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
} : {};
|
||||||
|
|
||||||
return api(getState)
|
return api(getState)
|
||||||
.patch('/api/v1/accounts/update_credentials', params, {
|
.patch('/api/v1/accounts/update_credentials', params, { headers })
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(response => {
|
.then(response => {
|
||||||
persistAuthAccount(response.data, params);
|
persistAuthAccount(response.data, params);
|
||||||
dispatch(patchMeSuccess(response.data));
|
dispatch(patchMeSuccess(response.data));
|
||||||
|
|
|
@ -197,7 +197,7 @@ const EditProfile: React.FC = () => {
|
||||||
const handleSubmit: React.FormEventHandler = (event) => {
|
const handleSubmit: React.FormEventHandler = (event) => {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
promises.push(dispatch(patchMe(data)));
|
promises.push(dispatch(patchMe(data, true)));
|
||||||
|
|
||||||
if (features.muteStrangers) {
|
if (features.muteStrangers) {
|
||||||
promises.push(
|
promises.push(
|
||||||
|
|
Loading…
Reference in a new issue