feat: skip status for flutter

This commit is contained in:
Kingtous 2022-12-05 20:09:48 +08:00
parent cbc372991b
commit 97066080bf
4 changed files with 25 additions and 4 deletions

View File

@ -458,7 +458,7 @@ class _FileManagerPageState extends State<FileManagerPage>
Wrap(
children: [
Text(
'${item.state.display()} ${max(0, item.fileNum)}/${item.fileCount} '),
'${item.display()} ${max(0, item.fileNum)}/${item.fileCount} '),
Text(
'${translate("files")} ${readableFileSize(item.totalSize.toDouble())} '),
Offstage(

View File

@ -268,6 +268,7 @@ class FileModel extends ChangeNotifier {
}
jobError(Map<String, dynamic> evt) {
final err = evt['err'].toString();
if (!isDesktop) {
if (_jobResultListener.isListening) {
_jobResultListener.complete(evt);
@ -275,12 +276,24 @@ class FileModel extends ChangeNotifier {
}
_selectMode = false;
_jobProgress.clear();
_jobProgress.err = err;
_jobProgress.state = JobState.error;
_jobProgress.fileNum = int.parse(evt['file_num']);
if (err == "skipped") {
_jobProgress.state = JobState.done;
_jobProgress.finishedSize = _jobProgress.totalSize;
}
} else {
int jobIndex = getJob(int.parse(evt['id']));
if (jobIndex != -1) {
final job = jobTable[jobIndex];
job.state = JobState.error;
job.err = err;
job.fileNum = int.parse(evt['file_num']);
if (err == "skipped") {
job.state = JobState.done;
job.finishedSize = job.totalSize;
}
}
}
debugPrint("jobError $evt");
@ -1089,6 +1102,7 @@ class JobProgress {
var remote = "";
var to = "";
var showHidden = false;
var err = "";
clear() {
state = JobState.none;
@ -1100,6 +1114,14 @@ class JobProgress {
fileCount = 0;
remote = "";
to = "";
err = "";
}
String display() {
if (state == JobState.done && err == "skipped") {
return translate("Skipped");
}
return state.display();
}
}

View File

@ -919,7 +919,6 @@ impl<T: InvokeUiSession> Remote<T> {
}
}
Some(file_response::Union::Block(block)) => {
log::debug!("recv block: {}", block.blk_id);
if let Some(job) = fs::get_job(block.id, &mut self.write_jobs) {
if let Err(_err) = job.write(block).await {
// to-do: add "skip" for writing job

View File

@ -210,10 +210,10 @@ impl InvokeUiSession for FlutterHandler {
);
}
fn job_done(&self, id: i32, file_num: i32, skipped: bool) {
fn job_done(&self, id: i32, file_num: i32) {
self.push_event(
"job_done",
vec![("id", &id.to_string()), ("file_num", &file_num.to_string()), ("skipped", skipped)],
vec![("id", &id.to_string()), ("file_num", &file_num.to_string())],
);
}