uploads: Don't call cancelAll when upload_files is called with no files.

Existing uploads should not be cancelled if upload_files
is called without any files.
This commit is contained in:
Vishnu KS 2020-04-14 22:55:01 +05:30 committed by Tim Abbott
parent fc086b7521
commit 2f2c384c88
2 changed files with 6 additions and 8 deletions

View File

@ -145,7 +145,7 @@ run_test('show_error_message', () => {
});
run_test('upload_files', () => {
let cancel_all_counter = 0;
let uppy_cancel_all_called = false;
const files = [
{
name: "budapest.png",
@ -155,7 +155,7 @@ run_test('upload_files', () => {
let uppy_add_file_called = false;
const uppy = {
cancelAll: () => {
cancel_all_counter += 1;
uppy_cancel_all_called = true;
},
addFile: (params) => {
uppy_add_file_called = true;
@ -171,10 +171,9 @@ run_test('upload_files', () => {
assert(config.mode, "compose");
};
const config = {mode: "compose"};
$("#compose-send-button").attr("disabled", false);
upload.upload_files(uppy, config, []);
assert.equal(cancel_all_counter, 1);
assert(hide_upload_status_called);
assert.equal($("#compose-send-button").attr("disabled"), false);
page_params.max_file_upload_size = 0;
let show_error_message_called = false;
@ -217,8 +216,9 @@ run_test('upload_files', () => {
func();
});
hide_upload_status_called = false;
uppy_cancel_all_called = false;
on_click_close_button_callback();
assert.equal(cancel_all_counter, 2);
assert(uppy_cancel_all_called);
assert(hide_upload_status_called);
});

View File

@ -91,8 +91,6 @@ exports.show_error_message = function (config, message) {
exports.upload_files = function (uppy, config, files) {
if (files.length === 0) {
uppy.cancelAll();
exports.hide_upload_status(config);
return;
}
if (page_params.max_file_upload_size === 0) {