diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-12-17 14:12:41 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-12-18 08:58:49 +0200 |
commit | 2b6f6ab42c4278cc2ff5f8c1819979d37b22ec50 (patch) | |
tree | 1c6b10b363837441738b02da24b30814d94401b0 /ui/src/components/mail/listing.rs | |
parent | 7bd2b6932deefe01986686cfb8dd4e080f39c429 (diff) |
melib: Add BackendFolder methods, move special usage logic to backend
- add count() method to return (unseen, total) counts
- add is_subscribed()
- add set_special_usage() and set_is_subscribed()
concerns #8
Diffstat (limited to 'ui/src/components/mail/listing.rs')
-rw-r--r-- | ui/src/components/mail/listing.rs | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index d2f7dd16..e792b84e 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -770,17 +770,11 @@ 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| &envelopes[&h]) - .filter(|e| !e.is_seen()) - .count() + m.folder.count().ok().map(|(v, _)| v).unwrap_or(0), ) }) } @@ -903,20 +897,12 @@ impl Listing { ) { match context.accounts[index].status(entries[&folder_idx].hash()) { Ok(_) => { - let account = &context.accounts[index]; - let count = account[entries[&folder_idx].hash()] - .unwrap() - .envelopes - .iter() - .filter_map(|&h| { - if account.collection.get_env(h).is_seen() { - None - } else { - Some(()) - } - }) - .count(); - lines.push((*depth, *inc, folder_idx, Some(count))); + lines.push(( + *depth, + *inc, + folder_idx, + entries[&folder_idx].count().ok().map(|(v, _)| v), + )); } Err(_) => { lines.push((*depth, *inc, folder_idx, None)); |