melib/thread: add attachments field to Thread
parent
5e68d600b9
commit
350fafb515
|
@ -139,17 +139,20 @@ macro_rules! make {
|
||||||
ref mut len,
|
ref mut len,
|
||||||
ref mut unseen,
|
ref mut unseen,
|
||||||
ref mut snoozed,
|
ref mut snoozed,
|
||||||
|
ref mut attachments,
|
||||||
..
|
..
|
||||||
}, ThreadGroup::Root(Thread {
|
}, ThreadGroup::Root(Thread {
|
||||||
date: old_date,
|
date: old_date,
|
||||||
len: old_len,
|
len: old_len,
|
||||||
unseen: old_unseen,
|
unseen: old_unseen,
|
||||||
snoozed: old_snoozed,
|
snoozed: old_snoozed,
|
||||||
|
attachments: old_attachments,
|
||||||
..
|
..
|
||||||
})) => {
|
})) => {
|
||||||
*date = std::cmp::max(old_date, *date);
|
*date = std::cmp::max(old_date, *date);
|
||||||
*len += old_len;
|
*len += old_len;
|
||||||
*unseen |= old_unseen;
|
*unseen += old_unseen;
|
||||||
|
*attachments += old_attachments;
|
||||||
*snoozed |= old_snoozed;
|
*snoozed |= old_snoozed;
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -273,6 +276,7 @@ pub struct Thread {
|
||||||
date: UnixTimestamp,
|
date: UnixTimestamp,
|
||||||
len: usize,
|
len: usize,
|
||||||
unseen: usize,
|
unseen: usize,
|
||||||
|
attachments: usize,
|
||||||
|
|
||||||
snoozed: bool,
|
snoozed: bool,
|
||||||
}
|
}
|
||||||
|
@ -321,6 +325,10 @@ impl Thread {
|
||||||
property!(snoozed: bool);
|
property!(snoozed: bool);
|
||||||
property!(date: UnixTimestamp);
|
property!(date: UnixTimestamp);
|
||||||
|
|
||||||
|
pub fn has_attachments(&self) -> bool {
|
||||||
|
self.attachments > 0
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_snoozed(&mut self, val: bool) {
|
pub fn set_snoozed(&mut self, val: bool) {
|
||||||
self.snoozed = val;
|
self.snoozed = val;
|
||||||
}
|
}
|
||||||
|
@ -765,6 +773,11 @@ impl Threads {
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
|
attachments: if envelopes_lck[&env_hash].has_attachments() {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
},
|
||||||
snoozed: false,
|
snoozed: false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -803,6 +816,7 @@ impl Threads {
|
||||||
date: envelopes_lck[&env_hash].date(),
|
date: envelopes_lck[&env_hash].date(),
|
||||||
len: 0,
|
len: 0,
|
||||||
unseen: 0,
|
unseen: 0,
|
||||||
|
attachments: 0,
|
||||||
snoozed: false,
|
snoozed: false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -846,6 +860,7 @@ impl Threads {
|
||||||
date: envelopes_lck[&env_hash].date(),
|
date: envelopes_lck[&env_hash].date(),
|
||||||
len: 0,
|
len: 0,
|
||||||
unseen: 0,
|
unseen: 0,
|
||||||
|
attachments: 0,
|
||||||
snoozed: false,
|
snoozed: false,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
@ -598,7 +598,7 @@ impl CompactListing {
|
||||||
subject: SubjectString(format!("{} ({})", subject, thread.len(),)),
|
subject: SubjectString(format!("{} ({})", subject, thread.len(),)),
|
||||||
flag: FlagString(format!(
|
flag: FlagString(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if e.has_attachments() { "π" } else { "" },
|
if thread.has_attachments() { "π" } else { "" },
|
||||||
if thread.snoozed() { "π€" } else { "" }
|
if thread.snoozed() { "π€" } else { "" }
|
||||||
)),
|
)),
|
||||||
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
||||||
|
@ -610,7 +610,7 @@ impl CompactListing {
|
||||||
subject: SubjectString(subject),
|
subject: SubjectString(subject),
|
||||||
flag: FlagString(format!(
|
flag: FlagString(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if e.has_attachments() { "π" } else { "" },
|
if thread.has_attachments() { "π" } else { "" },
|
||||||
if thread.snoozed() { "π€" } else { "" }
|
if thread.snoozed() { "π€" } else { "" }
|
||||||
)),
|
)),
|
||||||
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
||||||
|
@ -922,13 +922,7 @@ impl CompactListing {
|
||||||
self.data_columns.columns[4][(x, idx)].set_ch(' ');
|
self.data_columns.columns[4][(x, idx)].set_ch(' ');
|
||||||
self.data_columns.columns[4][(x, idx)].set_bg(bg_color);
|
self.data_columns.columns[4][(x, idx)].set_bg(bg_color);
|
||||||
}
|
}
|
||||||
match (
|
match (thread.snoozed(), thread.has_attachments()) {
|
||||||
thread.snoozed(),
|
|
||||||
context.accounts[self.cursor_pos.0]
|
|
||||||
.collection
|
|
||||||
.get_env(root_env_hash)
|
|
||||||
.has_attachments(),
|
|
||||||
) {
|
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
self.data_columns.columns[3][(0, idx)].set_fg(Color::Byte(103));
|
self.data_columns.columns[3][(0, idx)].set_fg(Color::Byte(103));
|
||||||
self.data_columns.columns[3][(2, idx)].set_fg(Color::Red);
|
self.data_columns.columns[3][(2, idx)].set_fg(Color::Red);
|
||||||
|
@ -994,7 +988,6 @@ impl CompactListing {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let envelope: EnvelopeRef = account.collection.get_env(env_hash);
|
let envelope: EnvelopeRef = account.collection.get_env(env_hash);
|
||||||
let has_attachments = envelope.has_attachments();
|
|
||||||
let fg_color = if thread.unseen() > 0 {
|
let fg_color = if thread.unseen() > 0 {
|
||||||
Color::Byte(0)
|
Color::Byte(0)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1119,7 +1112,7 @@ impl CompactListing {
|
||||||
columns[4][c].set_ch(' ');
|
columns[4][c].set_ch(' ');
|
||||||
columns[4][c].set_bg(bg_color);
|
columns[4][c].set_bg(bg_color);
|
||||||
}
|
}
|
||||||
match (thread.snoozed(), has_attachments) {
|
match (thread.snoozed(), thread.has_attachments()) {
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
columns[3][(0, idx)].set_fg(Color::Byte(103));
|
columns[3][(0, idx)].set_fg(Color::Byte(103));
|
||||||
columns[3][(2, idx)].set_fg(Color::Red);
|
columns[3][(2, idx)].set_fg(Color::Red);
|
||||||
|
|
|
@ -571,7 +571,7 @@ impl ConversationsListing {
|
||||||
subject: SubjectString(format!("{} ({})", subject, thread.len(),)),
|
subject: SubjectString(format!("{} ({})", subject, thread.len(),)),
|
||||||
flag: FlagString(format!(
|
flag: FlagString(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if e.has_attachments() { "π" } else { "" },
|
if thread.has_attachments() { "π" } else { "" },
|
||||||
if thread.snoozed() { "π€" } else { "" }
|
if thread.snoozed() { "π€" } else { "" }
|
||||||
)),
|
)),
|
||||||
from: FromString(address_list!((from) as comma_sep_list)),
|
from: FromString(address_list!((from) as comma_sep_list)),
|
||||||
|
@ -583,7 +583,7 @@ impl ConversationsListing {
|
||||||
subject: SubjectString(subject),
|
subject: SubjectString(subject),
|
||||||
flag: FlagString(format!(
|
flag: FlagString(format!(
|
||||||
"{}{}",
|
"{}{}",
|
||||||
if e.has_attachments() { "π" } else { "" },
|
if thread.has_attachments() { "π" } else { "" },
|
||||||
if thread.snoozed() { "π€" } else { "" }
|
if thread.snoozed() { "π€" } else { "" }
|
||||||
)),
|
)),
|
||||||
from: FromString(address_list!((from) as comma_sep_list)),
|
from: FromString(address_list!((from) as comma_sep_list)),
|
||||||
|
|
Loadingβ¦
Reference in New Issue