Skip to content

Commit d913f41

Browse files
committed
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>
1 parent e5b55b7 commit d913f41

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

apps/files/js/file-upload.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,24 @@ OC.Uploader.prototype = _.extend({
691691
// the upload info there still
692692
var self = this;
693693
var uploadId = upload.data.uploadId;
694+
// mark as deleted for the progress bar
695+
self._uploads[uploadId].deleted = true;
694696
window.setTimeout(function() {
695697
delete self._uploads[uploadId];
696698
}, 5000)
697699
},
698700

701+
_activeUploadCount: function() {
702+
var count = 0;
703+
for (var key in self._uploads) {
704+
if (!self._uploads[key].deleted) {
705+
count++;
706+
}
707+
}
708+
709+
return count;
710+
},
711+
699712
showUploadCancelMessage: _.debounce(function() {
700713
OC.Notification.show(t('files', 'Upload cancelled.'), {timeout : 7, type: 'error'});
701714
}, 500),
@@ -1321,9 +1334,9 @@ OC.Uploader.prototype = _.extend({
13211334

13221335
self._pendingUploadDoneCount++;
13231336

1324-
upload.done().then(function() {
1337+
upload.done().always(function() {
13251338
self._pendingUploadDoneCount--;
1326-
if (Object.keys(self._uploads).length === 0 && self._pendingUploadDoneCount === 0) {
1339+
if (self._activeUploadCount() === 0 && self._pendingUploadDoneCount === 0) {
13271340
// All the uploads ended and there is no pending
13281341
// operation, so hide the progress bar.
13291342
// Note that this happens here only with chunked
@@ -1337,7 +1350,7 @@ OC.Uploader.prototype = _.extend({
13371350
// hides the progress bar in that case).
13381351
self._hideProgressBar();
13391352
}
1340-
1353+
}).done(function() {
13411354
self.trigger('done', e, upload);
13421355
}).fail(function(status, response) {
13431356
if (upload.aborted) {

0 commit comments

Comments
 (0)