web: don't show mime type on attachment

This commit is contained in:
2024-04-03 20:28:51 -07:00
parent d8fef54606
commit a24f456136
5 changed files with 96 additions and 290 deletions

View File

@@ -642,14 +642,53 @@ fn message_render(msg: &ShowThreadQueryThreadMessages, open: bool) -> Node<Msg>
C!["view-part-text-html"],
raw![contents],
IF!(!msg.attachments.is_empty() =>
div![
C!["attachments"],
hr![],
h2!["Attachments"],
div![
C!["attachments"],
hr![],
h2!["Attachments"],
div![C!["grid","is-col-min-6"],
msg.attachments
.iter()
.map(|a| div!["Filename: ", &a.filename, " ", &a.content_type])
]),
.map(|a| {
let default = "UNKNOWN_FILE".to_string();
let filename = a.filename.as_ref().unwrap_or(&default);
let host = seed::window().location().host().expect("couldn't get host");
let url = format!("//{host}/download/attachment/{}/{}/{}", a.id,a.idx, filename);
div![
C!["attachment", "card"],
a.content_type.as_ref().map(|content_type|
IF!(content_type.starts_with("image/") =>
div![C!["card-image","is-1by1"],
div![
C!["image","is-1by1"],
style!{
St::BackgroundImage=>format!(r#"url("{url}");"#),
St::BackgroundSize=>"cover",
St::BackgroundPosition=>"center",
}
]
]
)),
div![C!["card-content"],
div![C!["content"],
&a.filename, br![],
small![&a.size, " bytes"]
]
],
footer![
C!["card-footer"],
a![C!["card-footer-item"],span![C!["icon"], i![C!["fas", "fa-download"]]],
ev(Ev::Click, move |_| {
seed::window().location().set_href(&url
).expect("failed to set URL");
})
]
]
]
})
]
]),
view_content_tree(&content_tree),
],
}