forked from OpenGamers/abaddon
handle multiple embeds in one message
This commit is contained in:
@@ -44,17 +44,21 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(const Message &d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// there should only ever be 1 embed (i think?)
|
if (!data.Embeds.empty()) {
|
||||||
if (data.Embeds.size() == 1) {
|
// todo refactor (all of) this lol
|
||||||
const auto &embed = data.Embeds[0];
|
auto *box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
|
||||||
if (IsEmbedImageOnly(embed)) {
|
container->m_embed_component = box;
|
||||||
auto *widget = container->CreateImageComponent(*embed.Thumbnail->ProxyURL, *embed.Thumbnail->URL, *embed.Thumbnail->Width, *embed.Thumbnail->Height);
|
container->m_main.add(*container->m_embed_component);
|
||||||
container->AttachEventHandlers(*widget);
|
for (const auto &embed : data.Embeds) {
|
||||||
container->m_main.add(*widget);
|
if (IsEmbedImageOnly(embed)) {
|
||||||
} else {
|
auto *widget = container->CreateImageComponent(*embed.Thumbnail->ProxyURL, *embed.Thumbnail->URL, *embed.Thumbnail->Width, *embed.Thumbnail->Height);
|
||||||
container->m_embed_component = container->CreateEmbedComponent(embed);
|
container->AttachEventHandlers(*widget);
|
||||||
container->AttachEventHandlers(*container->m_embed_component);
|
container->m_main.add(*widget);
|
||||||
container->m_main.add(*container->m_embed_component);
|
} else {
|
||||||
|
auto *widget = container->CreateEmbedComponent(embed);
|
||||||
|
container->AttachEventHandlers(*widget);
|
||||||
|
box->add(*widget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user