message-text: Don't use GtkBox for HTML is there is a single block

Seems to fix Gtk-CRITICALS for ContentMessageContent
This commit is contained in:
Kévin Commaille 2023-05-29 14:31:05 +02:00
parent 9d59cbac8d
commit c495d381c4
No known key found for this signature in database
GPG key ID: 29A48C1F03620416

View file

@ -212,13 +212,17 @@ impl MessageText {
}
fn build_html(&self, blocks: Vec<HtmlBlock>, room: &Room) {
let ellipsize = self.format() == ContentFormat::Ellipsized;
if blocks.len() == 1 {
let widget = create_widget_for_html_block(&blocks[0], room, ellipsize, false);
self.set_child(Some(&widget));
} else {
let child = gtk::Box::new(gtk::Orientation::Vertical, 6);
self.set_child(Some(&child));
let ellipsize = self.format() == ContentFormat::Ellipsized;
let len = blocks.len();
for block in blocks {
let widget = create_widget_for_html_block(&block, room, ellipsize, len > 1);
let widget = create_widget_for_html_block(&block, room, ellipsize, true);
child.append(&widget);
if ellipsize {
@ -226,6 +230,7 @@ impl MessageText {
}
}
}
}
/// The original text of the message that is displayed.
pub fn original_text(&self) -> String {