Browse Source

melib/jmap: impl watch() with polling

Concerns #22
lazy_fetch
Manos Pitsidianakis 11 months ago
parent
commit
50cd81772f
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 27
      melib/src/backends/jmap.rs

27
melib/src/backends/jmap.rs

@ -341,7 +341,32 @@ impl MailBackend for JmapType {
}
fn watch(&self) -> ResultFuture<()> {
Err(MeliError::from("JMAP watch for updates is unimplemented"))
let connection = self.connection.clone();
let store = self.store.clone();
Ok(Box::pin(async move {
{
let mut conn = connection.lock().await;
conn.connect().await?;
}
loop {
{
let mailbox_hashes = {
store
.mailboxes
.read()
.unwrap()
.keys()
.cloned()
.collect::<SmallVec<[MailboxHash; 16]>>()
};
let conn = connection.lock().await;
for mailbox_hash in mailbox_hashes {
conn.email_changes(mailbox_hash).await?;
}
}
crate::connections::sleep(std::time::Duration::from_secs(60)).await;
}
}))
}
fn mailboxes(&self) -> ResultFuture<HashMap<MailboxHash, Mailbox>> {

Loading…
Cancel
Save