accounts: make mailbox available as soon as possible

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/473/head
Manos Pitsidianakis 2 months ago
parent 53b0d035e4
commit 60833ee51d
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -917,6 +917,11 @@ impl Account {
self.main_loop_handler
.send(ThreadEvent::UIEvent(UIEvent::StatusEvent(ev)));
}
self.mailbox_entries
.entry(mailbox_hash)
.and_modify(|entry| {
entry.status = MailboxStatus::Parsing(0, 0);
});
let mailbox_job = self.backend.write().unwrap().fetch(mailbox_hash);
match mailbox_job {
Ok(mailbox_job) => {
@ -1439,6 +1444,7 @@ impl Account {
.into_iter()
.map(|e| (e.hash(), e))
.collect::<HashMap<EnvelopeHash, Envelope>>();
let len = envelopes.len();
if let Some(updated_mailboxes) = self.collection.merge(
envelopes,
mailbox_hash,
@ -1450,6 +1456,17 @@ impl Account {
));
}
}
self.mailbox_entries
.entry(mailbox_hash)
.and_modify(|entry| {
let prev_len =
if let MailboxStatus::Parsing(prev_len, _) = entry.status {
prev_len
} else {
0
};
entry.status = MailboxStatus::Parsing(prev_len + len, 0);
});
self.main_loop_handler.send(ThreadEvent::UIEvent(
UIEvent::MailboxUpdate((self.hash, mailbox_hash)),
));

Loading…
Cancel
Save