From fb126164ef6b4f1f30a4b46f17abdc253c55eb2c Mon Sep 17 00:00:00 2001 From: Starccy <452276725@qq.com> Date: Sun, 17 Oct 2021 21:50:34 +0800 Subject: [PATCH] use multiple jobs to delete --- src/ui/common.tis | 4 ++++ src/ui/file_transfer.tis | 41 +++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/ui/common.tis b/src/ui/common.tis index 316def2d4..6af29ab02 100644 --- a/src/ui/common.tis +++ b/src/ui/common.tis @@ -257,6 +257,10 @@ handler.msgbox = function(type, title, text, callback=null, height=180, width=50 self.timer(150ms, function() { msgbox(type, title, text, callback, height, width, retry); }); } +handler.block_msgbox = function(type, title, text, callback=null, height=180, width=500, retry=0) { + msgbox(type, title, text, callback, height, width, retry); +} + var reconnectTimeout = 1; handler.msgbox_retry = function(type, title, text, hasRetry, callback=null, height=180, width=500) { handler.msgbox(type, title, text, callback, height, width, hasRetry ? reconnectTimeout : 0); diff --git a/src/ui/file_transfer.tis b/src/ui/file_transfer.tis index 700efbdd2..74eaf2b69 100644 --- a/src/ui/file_transfer.tis +++ b/src/ui/file_transfer.tis @@ -407,20 +407,31 @@ class FolderView : Reactor.Component { } event click $(.trash) () { - var row = this.getCurrentRow(); - if (!row) return; - var path = row[0]; - var type = row[1]; - var new_history = []; - for (var i = 0; i < this.history.length; ++i) { - var h = this.history[i]; - if ((h + this.sep()).indexOf(path + this.sep()) == -1) new_history.push(h); + var rows = this.getCurrentRows(); + if (!rows || rows.length == 0) return; + + var delete_dirs = new Array(); + + for (var i = 0; i < rows.length; ++i) { + var row = rows[i]; + + var path = row[0]; + var type = row[1]; + + var new_history = []; + for (var j = 0; j < this.history.length; ++j) { + var h = this.history[j]; + if ((h + this.sep()).indexOf(path + this.sep()) == -1) new_history.push(h); + } + this.history = new_history; + if (type == 1) { + delete_dirs.push(path); + } else { + confirmDelete(path, this.is_remote); + } } - this.history = new_history; - if (type == 1) { - file_transfer.job_table.addDelDir(path, this.is_remote); - } else { - confirmDelete(path, this.is_remote); + for (var i = 0; i < delete_dirs.length; ++i) { + file_transfer.job_table.addDelDir(delete_dirs[i], this.is_remote); } } @@ -594,7 +605,7 @@ var deleting_single_file_jobs = {}; var create_dir_jobs = {} function confirmDelete(path, is_remote) { - handler.msgbox("custom-skip", "Confirm Delete", "
\ + handler.block_msgbox("custom-skip", "Confirm Delete", "
\
Are you sure you want to delete this file?
\ " + path + "
\
", function(res=null) { @@ -614,7 +625,7 @@ handler.confirmDeleteFiles = function(id, i, name) { if (i >= n) return; var file_path = job.path; if (name) file_path += handler.get_path_sep(job.is_remote) + name; - handler.msgbox("custom-skip", "Confirm Delete", "
\ + handler.block_msgbox("custom-skip", "Confirm Delete", "
\
Deleting #" + (i + 1) + " of " + n + " files.
\
Are you sure you want to delete this file?
\ " + name + "
\