melib/imap: on set_flags, update {un,}seen sets in all mailboxes

Some envelopes might be in several mailboxes, for example in Gmail's
implementation of IMAP.
pull/237/head
Manos Pitsidianakis 1 year ago
parent 363f493099
commit f5cfbd32e6
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -793,7 +793,7 @@ impl MailBackend for ImapType {
conn.read_response(&mut response, RequiredResponses::empty()) conn.read_response(&mut response, RequiredResponses::empty())
.await?; .await?;
if set_seen { if set_seen {
let f = &uid_store.mailboxes.lock().await[&mailbox_hash]; for f in uid_store.mailboxes.lock().await.values() {
if let Ok(mut unseen) = f.unseen.lock() { if let Ok(mut unseen) = f.unseen.lock() {
for env_hash in env_hashes.iter() { for env_hash in env_hashes.iter() {
unseen.remove(env_hash); unseen.remove(env_hash);
@ -801,6 +801,7 @@ impl MailBackend for ImapType {
}; };
} }
} }
}
if flags.iter().any(|(_, b)| !*b) { if flags.iter().any(|(_, b)| !*b) {
let mut set_unseen = false; let mut set_unseen = false;
/* Set flags/tags to false */ /* Set flags/tags to false */
@ -858,7 +859,7 @@ impl MailBackend for ImapType {
conn.read_response(&mut response, RequiredResponses::empty()) conn.read_response(&mut response, RequiredResponses::empty())
.await?; .await?;
if set_unseen { if set_unseen {
let f = &uid_store.mailboxes.lock().await[&mailbox_hash]; for f in uid_store.mailboxes.lock().await.values() {
if let Ok(mut unseen) = f.unseen.lock() { if let Ok(mut unseen) = f.unseen.lock() {
for env_hash in env_hashes.iter() { for env_hash in env_hashes.iter() {
unseen.insert_new(env_hash); unseen.insert_new(env_hash);
@ -866,6 +867,7 @@ impl MailBackend for ImapType {
}; };
} }
} }
}
Ok(()) Ok(())
})) }))
} }

Loading…
Cancel
Save