Lookup tag color/ignore settings in all three setting levels
There are three setting levels for tag settings: - per mailbox override ^ - per account override | - global setting | depth So lookup in each of them in this order for configuration, not just the deepest level.memfd
parent
06a58a70bd
commit
20b02ffd4f
|
@ -157,14 +157,14 @@ impl Composer {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
for (h, v) in
|
for (h, v) in
|
||||||
mailbox_acc_settings!(context[account_hash].composing.default_header_values).iter()
|
account_settings!(context[account_hash].composing.default_header_values).iter()
|
||||||
{
|
{
|
||||||
if v.is_empty() {
|
if v.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret.draft.set_header(h, v.into());
|
ret.draft.set_header(h, v.into());
|
||||||
}
|
}
|
||||||
if *mailbox_acc_settings!(context[account_hash].composing.insert_user_agent) {
|
if *account_settings!(context[account_hash].composing.insert_user_agent) {
|
||||||
ret.draft.set_header(
|
ret.draft.set_header(
|
||||||
"User-Agent",
|
"User-Agent",
|
||||||
format!("meli {}", option_env!("CARGO_PKG_VERSION").unwrap_or("0.0")),
|
format!("meli {}", option_env!("CARGO_PKG_VERSION").unwrap_or("0.0")),
|
||||||
|
@ -429,7 +429,7 @@ impl Composer {
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&format!(
|
&format!(
|
||||||
"☑ sign with {}",
|
"☑ sign with {}",
|
||||||
mailbox_acc_settings!(context[self.account_hash].pgp.key)
|
account_settings!(context[self.account_hash].pgp.key)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.as_str())
|
.map(|s| s.as_str())
|
||||||
.unwrap_or("default key")
|
.unwrap_or("default key")
|
||||||
|
@ -520,7 +520,7 @@ impl Component for Composer {
|
||||||
|
|
||||||
if !self.initialized {
|
if !self.initialized {
|
||||||
if self.sign_mail.is_unset() {
|
if self.sign_mail.is_unset() {
|
||||||
self.sign_mail = ToggleFlag::InternalVal(*mailbox_acc_settings!(
|
self.sign_mail = ToggleFlag::InternalVal(*account_settings!(
|
||||||
context[self.account_hash].pgp.auto_sign
|
context[self.account_hash].pgp.auto_sign
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -1078,8 +1078,7 @@ impl Component for Composer {
|
||||||
{
|
{
|
||||||
/* Edit draft in $EDITOR */
|
/* Edit draft in $EDITOR */
|
||||||
let editor = if let Some(editor_command) =
|
let editor = if let Some(editor_command) =
|
||||||
mailbox_acc_settings!(context[self.account_hash].composing.editor_command)
|
account_settings!(context[self.account_hash].composing.editor_command).as_ref()
|
||||||
.as_ref()
|
|
||||||
{
|
{
|
||||||
editor_command.to_string()
|
editor_command.to_string()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1104,7 +1103,7 @@ impl Component for Composer {
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
if *mailbox_acc_settings!(context[self.account_hash].composing.embed) {
|
if *account_settings!(context[self.account_hash].composing.embed) {
|
||||||
self.embed = Some(EmbedStatus::Running(
|
self.embed = Some(EmbedStatus::Running(
|
||||||
crate::terminal::embed::create_pty(
|
crate::terminal::embed::create_pty(
|
||||||
width!(self.embed_area),
|
width!(self.embed_area),
|
||||||
|
@ -1358,7 +1357,7 @@ impl Component for Composer {
|
||||||
};
|
};
|
||||||
|
|
||||||
let our_map: ShortcutMap =
|
let our_map: ShortcutMap =
|
||||||
mailbox_acc_settings!(context[self.account_hash].shortcuts.composing).key_values();
|
account_settings!(context[self.account_hash].shortcuts.composing).key_values();
|
||||||
map.insert(Composer::DESCRIPTION, our_map);
|
map.insert(Composer::DESCRIPTION, our_map);
|
||||||
|
|
||||||
map
|
map
|
||||||
|
@ -1411,7 +1410,7 @@ pub fn send_draft(
|
||||||
flags: Flag,
|
flags: Flag,
|
||||||
complete_in_background: bool,
|
complete_in_background: bool,
|
||||||
) -> Result<Option<(JobId, JoinHandle, JobChannel<()>)>> {
|
) -> Result<Option<(JobId, JoinHandle, JobChannel<()>)>> {
|
||||||
let format_flowed = *mailbox_acc_settings!(context[account_hash].composing.format_flowed);
|
let format_flowed = *account_settings!(context[account_hash].composing.format_flowed);
|
||||||
if sign_mail.is_true() {
|
if sign_mail.is_true() {
|
||||||
let mut content_type = ContentType::default();
|
let mut content_type = ContentType::default();
|
||||||
if format_flowed {
|
if format_flowed {
|
||||||
|
@ -1446,10 +1445,10 @@ pub fn send_draft(
|
||||||
}
|
}
|
||||||
let output = crate::components::mail::pgp::sign(
|
let output = crate::components::mail::pgp::sign(
|
||||||
body.into(),
|
body.into(),
|
||||||
mailbox_acc_settings!(context[account_hash].pgp.gpg_binary)
|
account_settings!(context[account_hash].pgp.gpg_binary)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.as_str()),
|
.map(|s| s.as_str()),
|
||||||
mailbox_acc_settings!(context[account_hash].pgp.key)
|
account_settings!(context[account_hash].pgp.key)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.as_str()),
|
.map(|s| s.as_str()),
|
||||||
);
|
);
|
||||||
|
@ -1498,7 +1497,7 @@ pub fn send_draft(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let bytes = draft.finalise().unwrap();
|
let bytes = draft.finalise().unwrap();
|
||||||
let send_mail = mailbox_acc_settings!(context[account_hash].composing.send_mail).clone();
|
let send_mail = account_settings!(context[account_hash].composing.send_mail).clone();
|
||||||
let ret =
|
let ret =
|
||||||
context.accounts[&account_hash].send(bytes.clone(), send_mail, complete_in_background);
|
context.accounts[&account_hash].send(bytes.clone(), send_mail, complete_in_background);
|
||||||
save_draft(bytes.as_bytes(), context, mailbox_type, flags, account_hash);
|
save_draft(bytes.as_bytes(), context, mailbox_type, flags, account_hash);
|
||||||
|
|
|
@ -928,6 +928,8 @@ impl CompactListing {
|
||||||
.ignore_tags
|
.ignore_tags
|
||||||
)
|
)
|
||||||
.contains(t)
|
.contains(t)
|
||||||
|
|| account_settings!(context[self.cursor_pos.0].tags.ignore_tags).contains(t)
|
||||||
|
|| context.settings.tags.ignore_tags.contains(t)
|
||||||
|| !tags_lck.contains_key(t)
|
|| !tags_lck.contains_key(t)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -938,7 +940,13 @@ impl CompactListing {
|
||||||
colors.push(
|
colors.push(
|
||||||
mailbox_settings!(context[self.cursor_pos.0][&self.cursor_pos.1].tags.colors)
|
mailbox_settings!(context[self.cursor_pos.0][&self.cursor_pos.1].tags.colors)
|
||||||
.get(t)
|
.get(t)
|
||||||
.map(|&c| c),
|
.cloned()
|
||||||
|
.or_else(|| {
|
||||||
|
account_settings!(context[self.cursor_pos.0].tags.colors)
|
||||||
|
.get(t)
|
||||||
|
.cloned()
|
||||||
|
.or_else(|| context.settings.tags.colors.get(t).cloned())
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if !tags.is_empty() {
|
if !tags.is_empty() {
|
||||||
|
|
|
@ -938,6 +938,8 @@ impl ConversationsListing {
|
||||||
.ignore_tags
|
.ignore_tags
|
||||||
)
|
)
|
||||||
.contains(t)
|
.contains(t)
|
||||||
|
|| account_settings!(context[self.cursor_pos.0].tags.ignore_tags).contains(t)
|
||||||
|
|| context.settings.tags.ignore_tags.contains(t)
|
||||||
|| !tags_lck.contains_key(t)
|
|| !tags_lck.contains_key(t)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -948,7 +950,13 @@ impl ConversationsListing {
|
||||||
colors.push(
|
colors.push(
|
||||||
mailbox_settings!(context[self.cursor_pos.0][&self.cursor_pos.1].tags.colors)
|
mailbox_settings!(context[self.cursor_pos.0][&self.cursor_pos.1].tags.colors)
|
||||||
.get(t)
|
.get(t)
|
||||||
.map(|&c| c),
|
.cloned()
|
||||||
|
.or_else(|| {
|
||||||
|
account_settings!(context[self.cursor_pos.0].tags.colors)
|
||||||
|
.get(t)
|
||||||
|
.cloned()
|
||||||
|
.or_else(|| context.settings.tags.colors.get(t).cloned())
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if !tags.is_empty() {
|
if !tags.is_empty() {
|
||||||
|
|
|
@ -743,6 +743,8 @@ impl PlainListing {
|
||||||
.ignore_tags
|
.ignore_tags
|
||||||
)
|
)
|
||||||
.contains(t)
|
.contains(t)
|
||||||
|
|| account_settings!(context[self.cursor_pos.0].tags.ignore_tags).contains(t)
|
||||||
|
|| context.settings.tags.ignore_tags.contains(t)
|
||||||
|| !tags_lck.contains_key(t)
|
|| !tags_lck.contains_key(t)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -753,7 +755,13 @@ impl PlainListing {
|
||||||
colors.push(
|
colors.push(
|
||||||
mailbox_settings!(context[self.cursor_pos.0][&self.cursor_pos.1].tags.colors)
|
mailbox_settings!(context[self.cursor_pos.0][&self.cursor_pos.1].tags.colors)
|
||||||
.get(t)
|
.get(t)
|
||||||
.map(|&c| c),
|
.cloned()
|
||||||
|
.or_else(|| {
|
||||||
|
account_settings!(context[self.cursor_pos.0].tags.colors)
|
||||||
|
.get(t)
|
||||||
|
.cloned()
|
||||||
|
.or_else(|| context.settings.tags.colors.get(t).cloned())
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if !tags.is_empty() {
|
if !tags.is_empty() {
|
||||||
|
|
|
@ -859,6 +859,8 @@ impl ThreadListing {
|
||||||
.ignore_tags
|
.ignore_tags
|
||||||
)
|
)
|
||||||
.contains(t)
|
.contains(t)
|
||||||
|
|| account_settings!(context[self.cursor_pos.0].tags.ignore_tags).contains(t)
|
||||||
|
|| context.settings.tags.ignore_tags.contains(t)
|
||||||
|| !tags_lck.contains_key(t)
|
|| !tags_lck.contains_key(t)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -869,7 +871,13 @@ impl ThreadListing {
|
||||||
colors.push(
|
colors.push(
|
||||||
mailbox_settings!(context[self.cursor_pos.0][&self.cursor_pos.1].tags.colors)
|
mailbox_settings!(context[self.cursor_pos.0][&self.cursor_pos.1].tags.colors)
|
||||||
.get(t)
|
.get(t)
|
||||||
.map(|&c| c),
|
.cloned()
|
||||||
|
.or_else(|| {
|
||||||
|
account_settings!(context[self.cursor_pos.0].tags.colors)
|
||||||
|
.get(t)
|
||||||
|
.cloned()
|
||||||
|
.or_else(|| context.settings.tags.colors.get(t).cloned())
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if !tags.is_empty() {
|
if !tags.is_empty() {
|
||||||
|
|
|
@ -78,7 +78,7 @@ macro_rules! split_command {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! mailbox_acc_settings {
|
macro_rules! account_settings {
|
||||||
($context:ident[$account_hash:expr].$setting:ident.$field:ident) => {{
|
($context:ident[$account_hash:expr].$setting:ident.$field:ident) => {{
|
||||||
$context.accounts[&$account_hash]
|
$context.accounts[&$account_hash]
|
||||||
.settings
|
.settings
|
||||||
|
|
Loading…
Reference in New Issue