better handle thumbnail server being down
This commit is contained in:
parent
04e3ca8250
commit
27da80083e
2 changed files with 22 additions and 6 deletions
14
dist/bundle.es.js
vendored
14
dist/bundle.es.js
vendored
|
@ -4216,6 +4216,7 @@ const doUpdatePublishForm = publishFormValue => dispatch => dispatch({
|
|||
});
|
||||
|
||||
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => dispatch => {
|
||||
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
||||
let thumbnail, fileExt, fileName, fileType;
|
||||
|
||||
const makeid = () => {
|
||||
|
@ -4226,6 +4227,8 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
|
|||
};
|
||||
|
||||
const uploadError = (error = '') => {
|
||||
console.log('error', error);
|
||||
|
||||
dispatch(batchActions({
|
||||
type: UPDATE_PUBLISH_FORM,
|
||||
data: {
|
||||
|
@ -4247,9 +4250,16 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
|
|||
uploadThumbnailStatus: COMPLETE,
|
||||
thumbnail: json.data.serveUrl
|
||||
}
|
||||
}) : uploadError(json.message || __('Thumbnail upload service may be down, try again later.'));
|
||||
}) : uploadError(json.message || downMessage);
|
||||
}).catch(err => {
|
||||
uploadError(err.message);
|
||||
let message = err.message;
|
||||
|
||||
// This sucks but ¯\_(ツ)_/¯
|
||||
if (message === 'Failed to fetch') {
|
||||
message = downMessage;
|
||||
}
|
||||
|
||||
uploadError(message);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ export const doUploadThumbnail = (
|
|||
fs?: any,
|
||||
path?: any
|
||||
) => (dispatch: Dispatch) => {
|
||||
const downMessage = __('Thumbnail upload service may be down, try again later.');
|
||||
let thumbnail, fileExt, fileName, fileType;
|
||||
|
||||
const makeid = () => {
|
||||
|
@ -111,12 +112,17 @@ export const doUploadThumbnail = (
|
|||
thumbnail: json.data.serveUrl,
|
||||
},
|
||||
})
|
||||
: uploadError(
|
||||
json.message || __('Thumbnail upload service may be down, try again later.')
|
||||
);
|
||||
: uploadError(json.message || downMessage);
|
||||
})
|
||||
.catch(err => {
|
||||
uploadError(err.message);
|
||||
let message = err.message;
|
||||
|
||||
// This sucks but ¯\_(ツ)_/¯
|
||||
if (message === 'Failed to fetch') {
|
||||
message = downMessage;
|
||||
}
|
||||
|
||||
uploadError(message);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue