ui: add From header in list unsubscribe e-mails
parent
a00e3fcbde
commit
ff37e97cba
|
@ -35,3 +35,12 @@ pub use self::compose::*;
|
|||
|
||||
mod accounts;
|
||||
pub use self::accounts::*;
|
||||
|
||||
fn get_display_name(context: &Context, idx: usize) -> String {
|
||||
let settings = context.accounts[idx].runtime_settings.account();
|
||||
if let Some(d) = settings.display_name.as_ref() {
|
||||
format!("{} <{}>", d, settings.identity)
|
||||
} else {
|
||||
settings.identity.to_string()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ impl Component for Composer {
|
|||
{
|
||||
self.draft.headers_mut().insert(
|
||||
"From".into(),
|
||||
get_display_name(context, self.account_cursor),
|
||||
crate::components::mail::get_display_name(context, self.account_cursor),
|
||||
);
|
||||
}
|
||||
self.pager.update_from_str(self.draft.body(), Some(77));
|
||||
|
@ -646,15 +646,6 @@ impl Component for Composer {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_display_name(context: &Context, idx: usize) -> String {
|
||||
let settings = context.accounts[idx].runtime_settings.account();
|
||||
if let Some(d) = settings.display_name.as_ref() {
|
||||
format!("{} <{}>", d, settings.identity)
|
||||
} else {
|
||||
settings.identity.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_draft(context: &mut Context, account_cursor: usize, draft: Draft) -> bool {
|
||||
use std::io::Write;
|
||||
use std::process::{Command, Stdio};
|
||||
|
|
|
@ -873,7 +873,14 @@ impl Component for MailView {
|
|||
match option {
|
||||
list_management::UnsubscribeOption::Email(email) => {
|
||||
if let Ok(mailto) = Mailto::try_from(email) {
|
||||
let draft: Draft = mailto.into();
|
||||
let mut draft: Draft = mailto.into();
|
||||
draft.headers_mut().insert(
|
||||
"From".into(),
|
||||
crate::components::mail::get_display_name(
|
||||
context,
|
||||
self.coordinates.0,
|
||||
),
|
||||
);
|
||||
if super::compose::send_draft(
|
||||
/* FIXME: refactor to avoid unsafe.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue