Merge pull request #431 from saltrafael/list-thumb

Changes for list thumbnail upload
This commit is contained in:
Thomas Zarebczan 2021-09-13 11:24:58 -04:00 committed by GitHub
commit 129b0ea3fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 13 deletions

10
dist/bundle.es.js vendored
View file

@ -5629,7 +5629,7 @@ const doUpdatePublishForm = publishFormValue => dispatch => dispatch({
data: _extends$7({}, publishFormValue)
});
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => dispatch => {
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path, cb) => dispatch => {
const downMessage = __('Thumbnail upload service may be down, try again later.');
let thumbnail, fileExt, fileName, fileType;
@ -5663,13 +5663,17 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
method: 'POST',
body: data
}).then(res => res.text()).then(text => text.length ? JSON.parse(text) : {}).then(json => {
return json.success ? dispatch({
if (!json.success) return uploadError(json.message || downMessage);
if (cb) {
cb(json.data.serveUrl);
}
return dispatch({
type: UPDATE_PUBLISH_FORM,
data: {
uploadThumbnailStatus: COMPLETE,
thumbnail: json.data.serveUrl
}
}) : uploadError(json.message || downMessage);
});
}).catch(err => {
let message = err.message;

View file

@ -69,7 +69,8 @@ export const doUploadThumbnail = (
thumbnailBlob?: File,
fsAdapter?: any,
fs?: any,
path?: any
path?: any,
cb?: (string) => void
) => (dispatch: Dispatch) => {
const downMessage = __('Thumbnail upload service may be down, try again later.');
let thumbnail, fileExt, fileName, fileType;
@ -112,15 +113,17 @@ export const doUploadThumbnail = (
.then(res => res.text())
.then(text => (text.length ? JSON.parse(text) : {}))
.then(json => {
return json.success
? dispatch({
type: ACTIONS.UPDATE_PUBLISH_FORM,
data: {
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
thumbnail: json.data.serveUrl,
},
})
: uploadError(json.message || downMessage);
if (!json.success) return uploadError(json.message || downMessage);
if (cb) {
cb(json.data.serveUrl);
}
return dispatch({
type: ACTIONS.UPDATE_PUBLISH_FORM,
data: {
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
thumbnail: json.data.serveUrl,
},
});
})
.catch(err => {
let message = err.message;