mail/status: display in-progress jobs first

jmap-eventsource
Manos Pitsidianakis 2020-12-01 18:25:56 +02:00
parent c5a5c2666b
commit 0f86934e16
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 50 additions and 49 deletions

View File

@ -90,6 +90,56 @@ impl Component for AccountStatus {
width = self.content.size().0; width = self.content.size().0;
let mut line = 2; let mut line = 2;
write_string_to_grid(
"In-progress jobs:",
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::BOLD,
((1, line), (width - 1, line)),
None,
);
line += 2;
for (job_id, req) in a.active_jobs.iter() {
width = self.content.size().0;
use crate::conf::accounts::JobRequest;
let (x, y) = write_string_to_grid(
&format!("{} {}", req, job_id),
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
((1, line), (width - 1, line)),
None,
);
if let JobRequest::DeleteMailbox { mailbox_hash, .. }
| JobRequest::SetMailboxPermissions { mailbox_hash, .. }
| JobRequest::SetMailboxSubscription { mailbox_hash, .. }
| JobRequest::CopyTo {
dest_mailbox_hash: mailbox_hash,
..
}
| JobRequest::Refresh { mailbox_hash, .. }
| JobRequest::Fetch { mailbox_hash, .. } = req
{
write_string_to_grid(
a.mailbox_entries[mailbox_hash].name(),
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
((x + 1, y), (width - 1, y)),
None,
);
}
line += 1;
}
line += 2;
width = self.content.size().0;
let (_x, _y) = write_string_to_grid( let (_x, _y) = write_string_to_grid(
"Tag support: ", "Tag support: ",
&mut self.content, &mut self.content,
@ -322,55 +372,6 @@ impl Component for AccountStatus {
line += 1; line += 1;
} }
} }
line += 2;
width = self.content.size().0;
write_string_to_grid(
"In-progress jobs:",
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::BOLD,
((1, line), (width - 1, line)),
None,
);
line += 2;
for (job_id, req) in a.active_jobs.iter() {
width = self.content.size().0;
use crate::conf::accounts::JobRequest;
let (x, y) = write_string_to_grid(
&format!("{} {}", req, job_id),
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
((1, line), (width - 1, line)),
None,
);
if let JobRequest::DeleteMailbox { mailbox_hash, .. }
| JobRequest::SetMailboxPermissions { mailbox_hash, .. }
| JobRequest::SetMailboxSubscription { mailbox_hash, .. }
| JobRequest::CopyTo {
dest_mailbox_hash: mailbox_hash,
..
}
| JobRequest::Refresh { mailbox_hash, .. }
| JobRequest::Fetch { mailbox_hash, .. } = req
{
write_string_to_grid(
a.mailbox_entries[mailbox_hash].name(),
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
((x + 1, y), (width - 1, y)),
None,
);
}
line += 1;
}
/* self.content may have been resized with write_string_to_grid() calls above since it has /* self.content may have been resized with write_string_to_grid() calls above since it has
* growable set */ * growable set */