update file transfer and adjust icon size

This commit is contained in:
csf
2022-09-06 19:08:45 +08:00
parent 82acb6a351
commit 235eb5415e
7 changed files with 76 additions and 58 deletions

View File

@@ -1665,6 +1665,7 @@ pub async fn handle_login_from_ui(
/// Interface for client to send data and commands.
#[async_trait]
pub trait Interface: Send + Clone + 'static + Sized {
/// Send message data to remote peer.
fn send(&self, data: Data);
fn msgbox(&self, msgtype: &str, title: &str, text: &str);
fn handle_login_error(&mut self, err: &str) -> bool;

View File

@@ -269,33 +269,6 @@ impl<T: InvokeUiSession> Remote<T> {
Some(tx)
}
// TODO
fn load_last_jobs(&mut self) {
self.handler.clear_all_jobs();
let pc = self.handler.load_config();
if pc.transfer.write_jobs.is_empty() && pc.transfer.read_jobs.is_empty() {
// no last jobs
return;
}
// TODO: can add a confirm dialog
let mut cnt = 1;
for job_str in pc.transfer.read_jobs.iter() {
if !job_str.is_empty() {
self.handler.load_last_job(cnt, job_str);
cnt += 1;
log::info!("restore read_job: {:?}", job_str);
}
}
for job_str in pc.transfer.write_jobs.iter() {
if !job_str.is_empty() {
self.handler.load_last_job(cnt, job_str);
cnt += 1;
log::info!("restore write_job: {:?}", job_str);
}
}
self.handler.update_transfer_list();
}
async fn handle_msg_from_ui(&mut self, data: Data, peer: &mut Stream) -> bool {
match data {
Data::Close => {
@@ -768,7 +741,7 @@ impl<T: InvokeUiSession> Remote<T> {
}
if self.handler.is_file_transfer() {
self.load_last_jobs();
self.handler.load_last_jobs();
}
}
_ => {}
@@ -827,7 +800,7 @@ impl<T: InvokeUiSession> Remote<T> {
&entries,
fd.path,
false,
fd.id > 0,
false,
);
if let Some(job) = fs::get_job(fd.id, &mut self.write_jobs) {
log::info!("job set_files: {:?}", entries);

View File

@@ -366,7 +366,7 @@ pub fn session_get_platform(id: String, is_remote: bool) -> String {
pub fn session_load_last_transfer_jobs(id: String) {
if let Some(session) = SESSIONS.read().unwrap().get(&id) {
// return session.load_last_jobs();
return session.load_last_jobs();
} else {
// a tip for flutter dev
eprintln!(

View File

@@ -532,6 +532,32 @@ impl<T: InvokeUiSession> Session<T> {
pub fn close(&self) {
self.send(Data::Close);
}
pub fn load_last_jobs(&self) {
self.clear_all_jobs();
let pc = self.load_config();
if pc.transfer.write_jobs.is_empty() && pc.transfer.read_jobs.is_empty() {
// no last jobs
return;
}
// TODO: can add a confirm dialog
let mut cnt = 1;
for job_str in pc.transfer.read_jobs.iter() {
if !job_str.is_empty() {
self.load_last_job(cnt, job_str);
cnt += 1;
log::info!("restore read_job: {:?}", job_str);
}
}
for job_str in pc.transfer.write_jobs.iter() {
if !job_str.is_empty() {
self.load_last_job(cnt, job_str);
cnt += 1;
log::info!("restore write_job: {:?}", job_str);
}
}
self.update_transfer_list();
}
}
pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {