Commit f8e9b9d62f
Unregistered key
Layout: unified · split
src/message/mod.rs +16 −29
| @@ -439,30 +439,10 @@ fn content_html(msgtype: &MessageType) -> Option<StyleTree> { | ||
| 439 | 439 | MessageType::Emote(content) => content.formatted.as_ref(), |
| 440 | 440 | MessageType::Notice(content) => content.formatted.as_ref(), |
| 441 | 441 | |
| 442 | MessageType::Audio(content) => content.formatted.as_ref(), | |
| 443 | MessageType::File(content) => content.formatted.as_ref(), | |
| 444 | MessageType::Video(content) => content.formatted.as_ref(), | |
| 445 | ||
| 446 | MessageType::Image(content) => { | |
| 447 | let mut html = if let Some(FormattedBody { format: MessageFormat::Html, body }) = | |
| 448 | &content.formatted | |
| 449 | { | |
| 450 | parse_matrix_html(body.as_str()) | |
| 451 | } else { | |
| 452 | StyleTree { children: vec![] } | |
| 453 | }; | |
| 454 | ||
| 455 | html.children | |
| 456 | .insert(0, html::StyleTreeNode::Text(display_file_name!(Image, content).into())); | |
| 457 | ||
| 458 | let src = content.source.clone(); | |
| 459 | html.children.insert( | |
| 460 | 0, | |
| 461 | html::StyleTreeNode::Image(html::Image::new(src, content.info.as_deref())), | |
| 462 | ); | |
| 463 | ||
| 464 | return Some(html); | |
| 465 | }, | |
| 442 | MessageType::Audio(content) => content.formatted_caption(), | |
| 443 | MessageType::File(content) => content.formatted_caption(), | |
| 444 | MessageType::Video(content) => content.formatted_caption(), | |
| 445 | MessageType::Image(content) => content.formatted_caption(), | |
| 466 | 446 | _ => None, |
| 467 | 447 | }; |
| 468 | 448 | |
| @@ -475,13 +455,20 @@ fn content_html(msgtype: &MessageType) -> Option<StyleTree> { | ||
| 475 | 455 | if let Some(filename) = content_filename(msgtype) { |
| 476 | 456 | let html = html.get_or_insert_with(|| { |
| 477 | 457 | let text = body_cow_content(msgtype).into_owned(); |
| 478 | StyleTree { | |
| 479 | children: vec![html::StyleTreeNode::Text(text.into())], | |
| 480 | } | |
| 458 | let text = html::StyleTreeNode::Text(text.into()); | |
| 459 | let text = html::StyleTreeNode::Paragraph(Box::new(text)); | |
| 460 | StyleTree { children: vec![text] } | |
| 481 | 461 | }); |
| 482 | 462 | |
| 483 | html.children.push(html::StyleTreeNode::Break); | |
| 484 | html.children.push(html::StyleTreeNode::Text(filename.into())); | |
| 463 | html.children.insert(0, html::StyleTreeNode::Text(filename.into())); | |
| 464 | ||
| 465 | if let MessageType::Image(content) = msgtype { | |
| 466 | let src = content.source.clone(); | |
| 467 | html.children.insert( | |
| 468 | 0, | |
| 469 | html::StyleTreeNode::Image(html::Image::new(src, content.info.as_deref())), | |
| 470 | ); | |
| 471 | } | |
| 485 | 472 | } |
| 486 | 473 | |
| 487 | 474 | html |