diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-01-18 03:00:02 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-01-20 16:03:06 +0200 |
commit | 350fafb51597e0e07fab731e111ae92b409b7834 (patch) | |
tree | dd689577becf7215cc3379d5bc84f48d9e8cbb7f /melib/src/thread.rs | |
parent | 5e68d600b9ac19ce318d9658d3a5508bb6e63516 (diff) |
melib/thread: add attachments field to Thread
Diffstat (limited to 'melib/src/thread.rs')
-rw-r--r-- | melib/src/thread.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/melib/src/thread.rs b/melib/src/thread.rs index 102ef914..405b68d0 100644 --- a/melib/src/thread.rs +++ b/melib/src/thread.rs @@ -139,17 +139,20 @@ macro_rules! make { ref mut len, ref mut unseen, ref mut snoozed, + ref mut attachments, .. }, ThreadGroup::Root(Thread { date: old_date, len: old_len, unseen: old_unseen, snoozed: old_snoozed, + attachments: old_attachments, .. })) => { *date = std::cmp::max(old_date, *date); *len += old_len; - *unseen |= old_unseen; + *unseen += old_unseen; + *attachments += old_attachments; *snoozed |= old_snoozed; } _ => unreachable!(), @@ -273,6 +276,7 @@ pub struct Thread { date: UnixTimestamp, len: usize, unseen: usize, + attachments: usize, snoozed: bool, } @@ -321,6 +325,10 @@ impl Thread { property!(snoozed: bool); property!(date: UnixTimestamp); + pub fn has_attachments(&self) -> bool { + self.attachments > 0 + } + pub fn set_snoozed(&mut self, val: bool) { self.snoozed = val; } @@ -765,6 +773,11 @@ impl Threads { } else { 0 }, + attachments: if envelopes_lck[&env_hash].has_attachments() { + 1 + } else { + 0 + }, snoozed: false, }), ); @@ -803,6 +816,7 @@ impl Threads { date: envelopes_lck[&env_hash].date(), len: 0, unseen: 0, + attachments: 0, snoozed: false, }), ); @@ -846,6 +860,7 @@ impl Threads { date: envelopes_lck[&env_hash].date(), len: 0, unseen: 0, + attachments: 0, snoozed: false, }), ); |