mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
delaying progress window for quick move/copy operations
This commit is contained in:
parent
440e832237
commit
2afb1a295b
@ -91,7 +91,7 @@ window.default_taskbar_height = 50;
|
|||||||
window.taskbar_height = window.default_taskbar_height;
|
window.taskbar_height = window.default_taskbar_height;
|
||||||
window.upload_progress_hide_delay = 500;
|
window.upload_progress_hide_delay = 500;
|
||||||
window.active_uploads = {};
|
window.active_uploads = {};
|
||||||
window.copy_progress_hide_delay = 1000;
|
window.copy_progress_hide_delay = 2000;
|
||||||
window.busy_indicator_hide_delay = 600;
|
window.busy_indicator_hide_delay = 600;
|
||||||
window.global_element_id = 0;
|
window.global_element_id = 0;
|
||||||
window.operation_id = 0;
|
window.operation_id = 0;
|
||||||
|
@ -1476,7 +1476,13 @@ window.copy_clipboard_items = async function(dest_path, dest_container_element){
|
|||||||
let overwrite_all = false;
|
let overwrite_all = false;
|
||||||
(async()=>{
|
(async()=>{
|
||||||
let copy_progress_window_init_ts = Date.now();
|
let copy_progress_window_init_ts = Date.now();
|
||||||
let progwin = await UIWindowCopyProgress({operation_id: copy_op_id});
|
|
||||||
|
// only show progress window if it takes longer than 2s to copy
|
||||||
|
let progwin;
|
||||||
|
let progwin_timeout = setTimeout(async () => {
|
||||||
|
progwin = await UIWindowCopyProgress({operation_id: copy_op_id});
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
for(let i=0; i<clipboard.length; i++){
|
for(let i=0; i<clipboard.length; i++){
|
||||||
let copy_path = clipboard[i].path;
|
let copy_path = clipboard[i].path;
|
||||||
let item_with_same_name_already_exists = true;
|
let item_with_same_name_already_exists = true;
|
||||||
@ -1531,10 +1537,12 @@ window.copy_clipboard_items = async function(dest_path, dest_container_element){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
|
clearTimeout(progwin_timeout);
|
||||||
|
|
||||||
let copy_duration = (Date.now() - copy_progress_window_init_ts);
|
let copy_duration = (Date.now() - copy_progress_window_init_ts);
|
||||||
if( copy_duration >= copy_progress_hide_delay){
|
if(progwin && copy_duration >= copy_progress_hide_delay){
|
||||||
$(progwin).close();
|
$(progwin).close();
|
||||||
}else{
|
}else if(progwin){
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$(progwin).close();
|
$(progwin).close();
|
||||||
@ -1555,7 +1563,13 @@ window.copy_items = function(el_items, dest_path){
|
|||||||
let overwrite_all = false;
|
let overwrite_all = false;
|
||||||
(async()=>{
|
(async()=>{
|
||||||
let copy_progress_window_init_ts = Date.now();
|
let copy_progress_window_init_ts = Date.now();
|
||||||
let progwin = await UIWindowCopyProgress({operation_id: copy_op_id});
|
|
||||||
|
// only show progress window if it takes longer than 2s to copy
|
||||||
|
let progwin;
|
||||||
|
let progwin_timeout = setTimeout(async () => {
|
||||||
|
progwin = await UIWindowCopyProgress({operation_id: copy_op_id});
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
for(let i=0; i < el_items.length; i++){
|
for(let i=0; i < el_items.length; i++){
|
||||||
let copy_path = $(el_items[i]).attr('data-path');
|
let copy_path = $(el_items[i]).attr('data-path');
|
||||||
let item_with_same_name_already_exists = true;
|
let item_with_same_name_already_exists = true;
|
||||||
@ -1612,10 +1626,12 @@ window.copy_items = function(el_items, dest_path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
|
clearTimeout(progwin_timeout);
|
||||||
|
|
||||||
let copy_duration = (Date.now() - copy_progress_window_init_ts);
|
let copy_duration = (Date.now() - copy_progress_window_init_ts);
|
||||||
if( copy_duration >= copy_progress_hide_delay){
|
if(progwin && copy_duration >= copy_progress_hide_delay){
|
||||||
$(progwin).close();
|
$(progwin).close();
|
||||||
}else{
|
}else if(progwin){
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$(progwin).close();
|
$(progwin).close();
|
||||||
@ -2250,8 +2266,11 @@ window.move_items = async function(el_items, dest_path){
|
|||||||
// when did this operation start
|
// when did this operation start
|
||||||
let move_init_ts = Date.now();
|
let move_init_ts = Date.now();
|
||||||
|
|
||||||
// create progress window
|
// only show progress window if it takes longer than 2s to move
|
||||||
let progwin = await UIWindowMoveProgress({operation_id: move_op_id});
|
let progwin;
|
||||||
|
let progwin_timeout = setTimeout(async () => {
|
||||||
|
progwin = await UIWindowMoveProgress({operation_id: move_op_id});
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
// Go through each item and try to move it
|
// Go through each item and try to move it
|
||||||
for(let i=0; i<el_items.length; i++){
|
for(let i=0; i<el_items.length; i++){
|
||||||
@ -2597,6 +2616,8 @@ window.move_items = async function(el_items, dest_path){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearTimeout(progwin_timeout);
|
||||||
|
|
||||||
// log stats to console
|
// log stats to console
|
||||||
let move_duration = (Date.now() - move_init_ts);
|
let move_duration = (Date.now() - move_init_ts);
|
||||||
console.log(`moved ${el_items.length} item${el_items.length > 1 ? 's':''} in ${move_duration}ms`);
|
console.log(`moved ${el_items.length} item${el_items.length > 1 ? 's':''} in ${move_duration}ms`);
|
||||||
@ -2604,9 +2625,11 @@ window.move_items = async function(el_items, dest_path){
|
|||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// DONE! close progress window with delay to allow user to see 100% progress
|
// DONE! close progress window with delay to allow user to see 100% progress
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
setTimeout(() => {
|
if(progwin){
|
||||||
$(progwin).close();
|
setTimeout(() => {
|
||||||
}, copy_progress_hide_delay);
|
$(progwin).close();
|
||||||
|
}, copy_progress_hide_delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user