Changes for list thumbnail upload #431
2 changed files with 20 additions and 13 deletions
10
dist/bundle.es.js
vendored
10
dist/bundle.es.js
vendored
|
@ -5628,7 +5628,7 @@ const doUpdatePublishForm = publishFormValue => dispatch => dispatch({
|
||||||
data: _extends$7({}, publishFormValue)
|
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.');
|
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
||||||
let thumbnail, fileExt, fileName, fileType;
|
let thumbnail, fileExt, fileName, fileType;
|
||||||
|
|
||||||
|
@ -5662,13 +5662,17 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: data
|
body: data
|
||||||
}).then(res => res.text()).then(text => text.length ? JSON.parse(text) : {}).then(json => {
|
}).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,
|
type: UPDATE_PUBLISH_FORM,
|
||||||
data: {
|
data: {
|
||||||
uploadThumbnailStatus: COMPLETE,
|
uploadThumbnailStatus: COMPLETE,
|
||||||
thumbnail: json.data.serveUrl
|
thumbnail: json.data.serveUrl
|
||||||
}
|
}
|
||||||
}) : uploadError(json.message || downMessage);
|
});
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
let message = err.message;
|
let message = err.message;
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,8 @@ export const doUploadThumbnail = (
|
||||||
thumbnailBlob?: File,
|
thumbnailBlob?: File,
|
||||||
fsAdapter?: any,
|
fsAdapter?: any,
|
||||||
fs?: any,
|
fs?: any,
|
||||||
path?: any
|
path?: any,
|
||||||
|
cb?: (string) => void
|
||||||
) => (dispatch: Dispatch) => {
|
) => (dispatch: Dispatch) => {
|
||||||
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
||||||
let thumbnail, fileExt, fileName, fileType;
|
let thumbnail, fileExt, fileName, fileType;
|
||||||
|
@ -112,15 +113,17 @@ export const doUploadThumbnail = (
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(text => (text.length ? JSON.parse(text) : {}))
|
.then(text => (text.length ? JSON.parse(text) : {}))
|
||||||
.then(json => {
|
.then(json => {
|
||||||
return json.success
|
if (!json.success) return uploadError(json.message || downMessage);
|
||||||
? dispatch({
|
if (cb) {
|
||||||
|
cb(json.data.serveUrl);
|
||||||
|
}
|
||||||
|
return dispatch({
|
||||||
type: ACTIONS.UPDATE_PUBLISH_FORM,
|
type: ACTIONS.UPDATE_PUBLISH_FORM,
|
||||||
data: {
|
data: {
|
||||||
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
uploadThumbnailStatus: THUMBNAIL_STATUSES.COMPLETE,
|
||||||
thumbnail: json.data.serveUrl,
|
thumbnail: json.data.serveUrl,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
: uploadError(json.message || downMessage);
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
let message = err.message;
|
let message = err.message;
|
||||||
|
|
Loading…
Reference in a new issue