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);
|
||||
assert.equal(add_file_counter, 1);
|
||||
|
||||
set_global("setTimeout", (func) => {
|
||||
func();
|
||||
});
|
||||
hide_upload_status_called = false;
|
||||
uppy_cancel_all_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));
|
||||
uppy.cancelAll();
|
||||
get_item("textarea", config).trigger("focus");
|
||||
setTimeout(() => {
|
||||
hide_upload_status(config);
|
||||
}, 500);
|
||||
hide_upload_status(config);
|
||||
});
|
||||
|
||||
for (const file of files) {
|
||||
|
@ -204,9 +202,14 @@ export function setup_upload(config) {
|
|||
},
|
||||
});
|
||||
|
||||
uppy.use(ProgressBar, {
|
||||
target: get_item("send_status_identifier", config),
|
||||
hideAfterFinish: false,
|
||||
uppy.on("progress", (progress) => {
|
||||
// When upload is complete, it resets to 0, but we want to see it at 100%.
|
||||
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) => {
|
||||
|
@ -279,9 +282,11 @@ export function setup_upload(config) {
|
|||
|
||||
const has_errors = get_item("send_status", config).hasClass("alert-error");
|
||||
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(() => {
|
||||
hide_upload_status(config);
|
||||
}, 500);
|
||||
}, 1100);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue