MM-22967 : Fixing file upload error feedback from server (#22972)

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Matheus
2023-05-02 21:25:08 -07:00
коммит произвёл GitHub
родитель f9f4553dae
Коммит 86f3a8bb1f
2 изменённых файлов: 17 добавлений и 3 удалений

Просмотреть файл

@@ -87,6 +87,20 @@ export function uploadFile({file, name, type, rootId, channelId, clientId, onPro
]));
onSuccess(response, channelId, rootId);
} else if (xhr.status >= 400 && xhr.readyState === 4) {
const errorResponse = JSON.parse(xhr.response);
const errorMessage =
(errorResponse?.id && errorResponse?.message) ? localizeMessage(errorResponse.id, errorResponse.message) :
localizeMessage('file_upload.generic_error', 'There was a problem uploading your files.');
dispatch({
type: FileTypes.UPLOAD_FILES_FAILURE,
clientIds: [clientId],
channelId,
rootId,
});
onError?.(errorMessage, clientId, channelId, rootId);
}
};
}

Просмотреть файл

@@ -998,9 +998,9 @@ class AdvancedCreatePost extends React.PureComponent<Props, State> {
};
handleUploadError = (err: string | ServerError, clientId?: string, channelId?: string) => {
let serverError = null;
if (typeof err === 'string' && err.length > 0) {
serverError = new Error(err);
let serverError = err;
if (typeof serverError === 'string') {
serverError = new Error(serverError);
}
if (!channelId || !clientId) {