melib/jmap: impl watch() with polling

Concerns #22
pull/144/head
Manos Pitsidianakis 4 years ago
parent 613c3de3d2
commit 50cd81772f
No known key found for this signature in database
GPG Key ID: 73627C2F690DF710

@ -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