From 3760489ffc7596a13909907c60d1410d8161b89e Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 8 Oct 2018 16:03:12 +0200 Subject: [PATCH] Superagent is a bit bogus --- frontend/js/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/js/app.js b/frontend/js/app.js index 2679187..c1a63a9 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -146,11 +146,16 @@ function uploadFiles(files) { var formData = new FormData(); formData.append('file', file); + var finishedUploadSize = app.uploadStatus.done; + superagent.post('/api/files' + path) .query({ access_token: localStorage.accessToken }) .send(formData) .on('progress', function (event) { - app.uploadStatus.done += event.loaded; + // only handle upload events + if (!(event.target instanceof XMLHttpRequestUpload)) return; + + app.uploadStatus.done = finishedUploadSize + event.loaded; app.uploadStatus.percentDone = Math.round(app.uploadStatus.done / app.uploadStatus.size * 100); }).end(function (error, result) { if (result && result.statusCode === 401) return logout(); -- 2.41.0