diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-11-02 12:14:31 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-11-08 15:13:41 +0200 |
commit | 78eecbb104c40baf1e3ffc5a18abf29baa8541bb (patch) | |
tree | 6bb10a8d0db06fccc1308b60a3b5cddb7a65c75b /ui/src/components/mail/listing.rs | |
parent | e9d17f6897d90d465859941a41e0511c1c3ae360 (diff) |
melib: Hide Envelope behind RwLock
Envelope can now only be accessed from within a RwLock. Two new structs
are introduced: EnvelopeRef and EnvelopeRefMut. These hold a reference
to an Envelope and the mutex guard that keeps them alive.
This change allows sharing of the envelopes hash map amongst threads.
Diffstat (limited to 'ui/src/components/mail/listing.rs')
-rw-r--r-- | ui/src/components/mail/listing.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index fca74936..d68b8742 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -579,13 +579,15 @@ impl Component for Listing { } else { return Some(String::new()); }; + let envelopes = account.collection.envelopes.clone(); + let envelopes = envelopes.read().unwrap(); format!( "Mailbox: {}, Messages: {}, New: {}", m.folder.name(), m.envelopes.len(), m.envelopes .iter() - .map(|h| &account.collection[&h]) + .map(|h| &envelopes[&h]) .filter(|e| !e.is_seen()) .count() ) @@ -714,8 +716,8 @@ impl Listing { .unwrap() .envelopes .iter() - .filter_map(|h| { - if account.collection[&h].is_seen() { + .filter_map(|&h| { + if account.collection.get_env(h).is_seen() { None } else { Some(()) |