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 2023-06-20 13:22:52 +03:00
parent 363f493099
commit f5cfbd32e6
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
1 changed files with 14 additions and 12 deletions

View File

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