diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-01-02 00:07:19 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2020-01-02 00:08:21 +0200 |
commit | 8694278369a312a1c4e605adedb7ed631c02c95a (patch) | |
tree | 1ed59609464687a9c320d211e312e930b758f6df /ui/src/components | |
parent | 3d84f3b9adaf97f10aa18aa24edc7234566eacaf (diff) |
ui: add auto_choose_multipart_alternative
Choose text/html by default if text/plain is empty in
multipart/alternative attachments
This happens in some newsletters I've come upon
Diffstat (limited to 'ui/src/components')
-rw-r--r-- | ui/src/components/mail/view.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index a6328eae..7fcf78b4 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -21,6 +21,7 @@ use super::*; use melib::list_management; +use melib::parser::BytesExt; use std::convert::TryFrom; use std::process::{Command, Stdio}; @@ -605,6 +606,35 @@ impl Component for MailView { self.subview = Some(Box::new(HtmlView::new(&body, context))); self.mode = ViewMode::Subview; } + ViewMode::Normal + if context + .settings + .pager + .auto_choose_multipart_alternative + .is_true() + && match body.content_type { + ContentType::Multipart { + kind: MultipartType::Alternative, + ref parts, + .. + } => parts.iter().all(|p| { + p.is_html() || (p.is_text() && p.body().trim().is_empty()) + }), + _ => false, + } => + { + self.subview = Some(Box::new(HtmlView::new( + &body + .content_type + .parts() + .unwrap() + .into_iter() + .find(|a| a.is_html()) + .unwrap_or(&body), + context, + ))); + self.mode = ViewMode::Subview; + } ViewMode::Subview | ViewMode::ContactSelector(_) => {} ViewMode::Raw => { let text = { |