better handle thumbnail server being down

This commit is contained in:
Sean Yesmunt 2020-08-10 17:31:29 -04:00
parent 04e3ca8250
commit 27da80083e
2 changed files with 22 additions and 6 deletions

14
dist/bundle.es.js vendored
View file

@ -4216,6 +4216,7 @@ const doUpdatePublishForm = publishFormValue => dispatch => dispatch({
}); });
const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => 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; let thumbnail, fileExt, fileName, fileType;
const makeid = () => { const makeid = () => {
@ -4226,6 +4227,8 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
}; };
const uploadError = (error = '') => { const uploadError = (error = '') => {
console.log('error', error);
dispatch(batchActions({ dispatch(batchActions({
type: UPDATE_PUBLISH_FORM, type: UPDATE_PUBLISH_FORM,
data: { data: {
@ -4247,9 +4250,16 @@ const doUploadThumbnail = (filePath, thumbnailBlob, fsAdapter, fs, path) => disp
uploadThumbnailStatus: COMPLETE, uploadThumbnailStatus: COMPLETE,
thumbnail: json.data.serveUrl thumbnail: json.data.serveUrl
} }
}) : uploadError(json.message || __('Thumbnail upload service may be down, try again later.')); }) : uploadError(json.message || downMessage);
}).catch(err => { }).catch(err => {
uploadError(err.message); let message = err.message;
// This sucks but ¯\_(ツ)_/¯
if (message === 'Failed to fetch') {
message = downMessage;
}
uploadError(message);
}); });
}; };

View file

@ -70,6 +70,7 @@ export const doUploadThumbnail = (
fs?: any, fs?: any,
path?: any path?: any
) => (dispatch: Dispatch) => { ) => (dispatch: Dispatch) => {
const downMessage = __('Thumbnail upload service may be down, try again later.');
let thumbnail, fileExt, fileName, fileType; let thumbnail, fileExt, fileName, fileType;
const makeid = () => { const makeid = () => {
@ -111,12 +112,17 @@ export const doUploadThumbnail = (
thumbnail: json.data.serveUrl, thumbnail: json.data.serveUrl,
}, },
}) })
: uploadError( : uploadError(json.message || downMessage);
json.message || __('Thumbnail upload service may be down, try again later.')
);
}) })
.catch(err => { .catch(err => {
uploadError(err.message); let message = err.message;
// This sucks but ¯\_(ツ)_/¯
if (message === 'Failed to fetch') {
message = downMessage;
}
uploadError(message);
}); });
}; };