patchMe(): use multipart/form-data only optionally

feed-suggestions
Alex Gleason 2022-07-05 21:04:42 -05:00
rodzic d6d4fd2b91
commit 9ce9a3f951
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 8 dodań i 8 usunięć

Wyświetl plik

@ -6,7 +6,7 @@ import api from '../api';
import { loadCredentials } from './auth';
import { importFetchedAccount } from './importer';
import type { AxiosError } from 'axios';
import type { AxiosError, AxiosRequestHeaders } from 'axios';
import type { AppDispatch, RootState } from 'soapbox/store';
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(patchMeRequest());
const headers: AxiosRequestHeaders = isFormData ? {
'Content-Type': 'multipart/form-data',
} : {};
return api(getState)
.patch('/api/v1/accounts/update_credentials', params, {
headers: {
'Content-Type': 'multipart/form-data',
},
})
.patch('/api/v1/accounts/update_credentials', params, { headers })
.then(response => {
persistAuthAccount(response.data, params);
dispatch(patchMeSuccess(response.data));

Wyświetl plik

@ -197,7 +197,7 @@ const EditProfile: React.FC = () => {
const handleSubmit: React.FormEventHandler = (event) => {
const promises = [];
promises.push(dispatch(patchMe(data)));
promises.push(dispatch(patchMe(data, true)));
if (features.muteStrangers) {
promises.push(