summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-02-02 22:46:55 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2022-02-02 22:46:55 -0500
commit75213fcede7388e4390660fa2aa12ff253617fab (patch)
treef58c2eb50b216d9f9503cb1f8c18941980c461b6
parent179ff980e93b1e4f54127b474785b5f0dde3cdc1 (diff)
downloadabaddon-portaudio-75213fcede7388e4390660fa2aa12ff253617fab.tar.gz
abaddon-portaudio-75213fcede7388e4390660fa2aa12ff253617fab.zip
handle multiple embeds in one message
-rw-r--r--src/components/chatmessage.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp
index ef972bb..e5a65cd 100644
--- a/src/components/chatmessage.cpp
+++ b/src/components/chatmessage.cpp
@@ -44,17 +44,21 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(const Message &d
}
}
- // there should only ever be 1 embed (i think?)
- if (data.Embeds.size() == 1) {
- const auto &embed = data.Embeds[0];
- if (IsEmbedImageOnly(embed)) {
- auto *widget = container->CreateImageComponent(*embed.Thumbnail->ProxyURL, *embed.Thumbnail->URL, *embed.Thumbnail->Width, *embed.Thumbnail->Height);
- container->AttachEventHandlers(*widget);
- container->m_main.add(*widget);
- } else {
- container->m_embed_component = container->CreateEmbedComponent(embed);
- container->AttachEventHandlers(*container->m_embed_component);
- container->m_main.add(*container->m_embed_component);
+ if (!data.Embeds.empty()) {
+ // todo refactor (all of) this lol
+ auto *box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
+ container->m_embed_component = box;
+ container->m_main.add(*container->m_embed_component);
+ for (const auto &embed : data.Embeds) {
+ if (IsEmbedImageOnly(embed)) {
+ auto *widget = container->CreateImageComponent(*embed.Thumbnail->ProxyURL, *embed.Thumbnail->URL, *embed.Thumbnail->Width, *embed.Thumbnail->Height);
+ container->AttachEventHandlers(*widget);
+ container->m_main.add(*widget);
+ } else {
+ auto *widget = container->CreateEmbedComponent(embed);
+ container->AttachEventHandlers(*widget);
+ box->add(*widget);
+ }
}
}