Notify: auto-retry once after 10 seconds
Also: - Show the resume button on notify errors. - Changed the error message to differentiate against v1's.
This commit is contained in:
parent
b5f1ae1291
commit
7ef5975ee8
1 changed files with 29 additions and 18 deletions
|
@ -56,7 +56,9 @@ export function makeResumableUploadRequest(
|
|||
window.store.dispatch(doUpdateUploadProgress({ params, progress: percentage }));
|
||||
},
|
||||
onSuccess: () => {
|
||||
// Notify lbrynet server
|
||||
let retries = 2;
|
||||
|
||||
function makeNotifyRequest() {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', `${uploader.url}/notify`);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
|
@ -68,13 +70,22 @@ export function makeResumableUploadRequest(
|
|||
resolve(xhr);
|
||||
};
|
||||
xhr.onerror = () => {
|
||||
reject(new Error(__('There was a problem with your upload. Please try again.')));
|
||||
if (--retries > 0) {
|
||||
// Auto-retry after 10s delay.
|
||||
setTimeout(() => makeNotifyRequest(), 10000);
|
||||
} else {
|
||||
window.store.dispatch(doUpdateUploadProgress({ params, status: 'error' }));
|
||||
reject(new Error(__('There was a problem in the processing. Please retry.')));
|
||||
}
|
||||
};
|
||||
xhr.onabort = () => {
|
||||
window.store.dispatch(doUpdateUploadRemove(params));
|
||||
};
|
||||
|
||||
xhr.send(jsonPayload);
|
||||
}
|
||||
|
||||
makeNotifyRequest();
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue