Merge pull request #571 from vector-im/fix-570

Make progress bar work for image uploads in Chrome
This commit is contained in:
Bruno Windels 2021-11-05 15:56:33 +01:00 committed by GitHub
commit 1fee773313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,11 @@ class RequestResult {
function createXhr(url, {method, headers, timeout, format, uploadProgress}) {
const xhr = new XMLHttpRequest();
if (uploadProgress) {
xhr.upload.addEventListener("progress", evt => uploadProgress(evt.loaded));
}
xhr.open(method, url);
if (format === "buffer") {
@ -56,10 +61,6 @@ function createXhr(url, {method, headers, timeout, format, uploadProgress}) {
xhr.timeout = timeout;
}
if (uploadProgress) {
xhr.upload.addEventListener("progress", evt => uploadProgress(evt.loaded));
}
return xhr;
}