summaryrefslogtreecommitdiffstats
path: root/melib/src/collection.rs
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-06-23 12:27:10 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-06-23 12:27:10 +0300
commiteca1921a8a7bb16495d311b95936c785d82de6d5 (patch)
tree9565d2ec1957e6ba8c72afb5d3afe2c790db5fc8 /melib/src/collection.rs
parentcac21a279bbb2209e281c461cac831a746c9c143 (diff)
collection: add update_flags() method
On NewFlags events, the threads in Collection were not being updated, so if an envelope's seen status was toggled the thread's unseen count was not updated, and thus not reflected in the UI even though the envelope's new flags event was registered properly.
Diffstat (limited to 'melib/src/collection.rs')
-rw-r--r--melib/src/collection.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/melib/src/collection.rs b/melib/src/collection.rs
index a677c5de..159626ac 100644
--- a/melib/src/collection.rs
+++ b/melib/src/collection.rs
@@ -351,6 +351,43 @@ impl Collection {
}
}
+ pub fn update_flags(&mut self, env_hash: EnvelopeHash, mailbox_hash: MailboxHash) {
+ if self
+ .sent_mailbox
+ .map(|f| f == mailbox_hash)
+ .unwrap_or(false)
+ {
+ for (_, t) in self.threads.iter_mut() {
+ t.update_envelope(&self.envelopes, env_hash, env_hash)
+ .unwrap_or(());
+ }
+ }
+ {
+ if self
+ .threads
+ .entry(mailbox_hash)
+ .or_default()
+ .update_envelope(&self.envelopes, env_hash, env_hash)
+ .is_ok()
+ {
+ return;
+ }
+ }
+ /* envelope is not in threads, so insert it */
+ self.threads
+ .entry(mailbox_hash)
+ .or_default()
+ .insert(&mut self.envelopes, env_hash);
+ for (h, t) in self.threads.iter_mut() {
+ if *h == mailbox_hash {
+ continue;
+ }
+ t.update_envelope(&self.envelopes, env_hash, env_hash)
+ .ok()
+ .take();
+ }
+ }
+
pub fn insert(&mut self, envelope: Envelope, mailbox_hash: MailboxHash) -> bool {
let hash = envelope.hash();
if self.message_ids.contains_key(envelope.message_id().raw()) {