mirror of https://github.com/zulip/zulip.git
upload: Remove and reduce timeouts for closing upload bar.
This timeout was introduced in this commit: 02c3223985
The UI should close immediately when the user clicks cancel,
and the rest of the canceling code can run behind the scenes.
We want to keep a short timeout for upload completion
so that the user sees the 100% complete upload bar.
This commit is contained in:
parent
beef7611da
commit
b01ac3623f
|
@ -277,9 +277,6 @@ test("upload_files", ({override_rewire}) => {
|
||||||
upload.upload_files(uppy, config, files);
|
upload.upload_files(uppy, config, files);
|
||||||
assert.equal(add_file_counter, 1);
|
assert.equal(add_file_counter, 1);
|
||||||
|
|
||||||
set_global("setTimeout", (func) => {
|
|
||||||
func();
|
|
||||||
});
|
|
||||||
hide_upload_status_called = false;
|
hide_upload_status_called = false;
|
||||||
uppy_cancel_all_called = false;
|
uppy_cancel_all_called = false;
|
||||||
let compose_ui_replace_syntax_called = false;
|
let compose_ui_replace_syntax_called = false;
|
||||||
|
|
|
@ -141,9 +141,7 @@ export function upload_files(uppy, config, files) {
|
||||||
compose_ui.autosize_textarea(get_item("textarea", config));
|
compose_ui.autosize_textarea(get_item("textarea", config));
|
||||||
uppy.cancelAll();
|
uppy.cancelAll();
|
||||||
get_item("textarea", config).trigger("focus");
|
get_item("textarea", config).trigger("focus");
|
||||||
setTimeout(() => {
|
hide_upload_status(config);
|
||||||
hide_upload_status(config);
|
|
||||||
}, 500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
|
@ -204,9 +202,14 @@ export function setup_upload(config) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
uppy.use(ProgressBar, {
|
uppy.on("progress", (progress) => {
|
||||||
target: get_item("send_status_identifier", config),
|
// When upload is complete, it resets to 0, but we want to see it at 100%.
|
||||||
hideAfterFinish: false,
|
if (progress === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$(`${get_item("send_status_identifier", config)} .moving_bar`).css({
|
||||||
|
width: `${progress}%`,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("body").on("change", get_item("file_input_identifier", config), (event) => {
|
$("body").on("change", get_item("file_input_identifier", config), (event) => {
|
||||||
|
@ -279,9 +282,11 @@ export function setup_upload(config) {
|
||||||
|
|
||||||
const has_errors = get_item("send_status", config).hasClass("alert-error");
|
const has_errors = get_item("send_status", config).hasClass("alert-error");
|
||||||
if (!uploads_in_progress && !has_errors) {
|
if (!uploads_in_progress && !has_errors) {
|
||||||
|
// Hide upload status for 100ms after the 1s transition to 100%
|
||||||
|
// so that the user can see the progress bar at 100%.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
hide_upload_status(config);
|
hide_upload_status(config);
|
||||||
}, 500);
|
}, 1100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue