Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-01-12 18:39:45 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2022-01-13 11:32:41 +0300
commit8a9fcb611e9dad0de7fb117a212fa058d61dd8a2 (patch)
treef0e8d826607f927f6df6037e6ae1d8d37f5c9dec /apps/files
parentdb64ed77cacc2448a59e48eb9df91d8ac28ee884 (diff)
Properly hide progress bar after error
Whenever an error occurs, also hide the progress bar. The logic was also adjusted to properly detect uploads that are pending deletion, in which case the progress bar can already be hidden. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/js/file-upload.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 64a12e0846d..9dec0de0846 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -323,7 +323,6 @@ OC.FileUpload.prototype = {
},
_delete: function() {
- var self = this;
if (this.data.isChunked) {
this._deleteChunkFolder()
}
@@ -334,7 +333,6 @@ OC.FileUpload.prototype = {
* Abort the upload
*/
abort: function() {
- var self = this;
if (this.aborted) {
return
}
@@ -691,11 +689,24 @@ OC.Uploader.prototype = _.extend({
// the upload info there still
var self = this;
var uploadId = upload.data.uploadId;
+ // mark as deleted for the progress bar
+ this._uploads[uploadId].deleted = true;
window.setTimeout(function() {
delete self._uploads[uploadId];
}, 5000)
},
+ _activeUploadCount: function() {
+ var count = 0;
+ for (var key in this._uploads) {
+ if (!this._uploads[key].deleted) {
+ count++;
+ }
+ }
+
+ return count;
+ },
+
showUploadCancelMessage: _.debounce(function() {
OC.Notification.show(t('files', 'Upload cancelled.'), {timeout : 7, type: 'error'});
}, 500),
@@ -1321,9 +1332,9 @@ OC.Uploader.prototype = _.extend({
self._pendingUploadDoneCount++;
- upload.done().then(function() {
+ upload.done().always(function() {
self._pendingUploadDoneCount--;
- if (Object.keys(self._uploads).length === 0 && self._pendingUploadDoneCount === 0) {
+ if (self._activeUploadCount() === 0 && self._pendingUploadDoneCount === 0) {
// All the uploads ended and there is no pending
// operation, so hide the progress bar.
// Note that this happens here only with chunked
@@ -1337,7 +1348,7 @@ OC.Uploader.prototype = _.extend({
// hides the progress bar in that case).
self._hideProgressBar();
}
-
+ }).done(function() {
self.trigger('done', e, upload);
}).fail(function(status, response) {
if (upload.aborted) {