ui: add From header in list unsubscribe e-mails

embed
Manos Pitsidianakis 2019-07-22 15:14:39 +03:00
parent a00e3fcbde
commit ff37e97cba
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
3 changed files with 18 additions and 11 deletions

View File

@ -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()
}
}

View File

@ -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};

View File

@ -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.
*