summaryrefslogtreecommitdiff
path: root/src/components/chatmessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/chatmessage.cpp')
-rw-r--r--src/components/chatmessage.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/components/chatmessage.cpp b/src/components/chatmessage.cpp
index ef972bb..d34730b 100644
--- a/src/components/chatmessage.cpp
+++ b/src/components/chatmessage.cpp
@@ -1,7 +1,7 @@
-#include "chatmessage.hpp"
#include "abaddon.hpp"
-#include "util.hpp"
+#include "chatmessage.hpp"
#include "lazyimage.hpp"
+#include "util.hpp"
#include <unordered_map>
constexpr static int EmojiSize = 24; // settings eventually
@@ -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);
+ }
}
}
@@ -1064,11 +1068,11 @@ ChatMessageHeader::ChatMessageHeader(const Message &data)
};
img.LoadFromURL(author->GetAvatarURL(data.GuildID), sigc::track_obj(cb, *this));
- if (author->HasAnimatedAvatar()) {
+ if (author->HasAnimatedAvatar(data.GuildID)) {
auto cb = [this](const Glib::RefPtr<Gdk::PixbufAnimation> &pb) {
m_anim_avatar = pb;
};
- img.LoadAnimationFromURL(author->GetAvatarURL("gif"), AvatarSize, AvatarSize, sigc::track_obj(cb, *this));
+ img.LoadAnimationFromURL(author->GetAvatarURL(data.GuildID, "gif"), AvatarSize, AvatarSize, sigc::track_obj(cb, *this));
}
get_style_context()->add_class("message-container");