From 1936f9ab8ab8687e3200a0ea31937339f9264c9e Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 26 Jul 2021 02:47:20 -0400 Subject: handle THREAD_CREATED message type --- components/chatmessage.cpp | 12 ++++++++++-- discord/message.hpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp index 63db7e9..b7cdf17 100644 --- a/components/chatmessage.cpp +++ b/components/chatmessage.cpp @@ -38,8 +38,10 @@ ChatMessageItemContainer *ChatMessageItemContainer::FromMessage(const Message &d if ((data.MessageReference.has_value() || data.Interaction.has_value()) && data.Type != MessageType::CHANNEL_FOLLOW_ADD) { auto *widget = container->CreateReplyComponent(data); - container->m_main.add(*widget); - container->m_main.child_property_position(*widget) = 0; // eek + if (widget != nullptr) { + container->m_main.add(*widget); + container->m_main.child_property_position(*widget) = 0; // eek + } } // there should only ever be 1 embed (i think?) @@ -274,6 +276,10 @@ void ChatMessageItemContainer::UpdateTextComponent(Gtk::TextView *tv) { case MessageType::GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING: { b->insert_markup(s, "This server has failed Discovery activity requirements for 3 weeks in a row. If this server fails for 1 more week, it will be removed from Discovery."); } break; + case MessageType::THREAD_CREATED: { + const auto author = Abaddon::Get().GetDiscordClient().GetUser(data->Author.ID); + b->insert_markup(s, "" + author->GetEscapedBoldName() + " started a thread: " + Glib::Markup::escape_text(data->Content) + ""); + } break; default: break; } } @@ -607,6 +613,8 @@ Gtk::Widget *ChatMessageItemContainer::CreateReactionsComponent(const Message &d } Gtk::Widget *ChatMessageItemContainer::CreateReplyComponent(const Message &data) { + if (data.Type == MessageType::THREAD_CREATED) return nullptr; + auto *box = Gtk::manage(new Gtk::Box); auto *lbl = Gtk::manage(new Gtk::Label); lbl->set_single_line_mode(true); diff --git a/discord/message.hpp b/discord/message.hpp index a6ea039..56f4c0f 100644 --- a/discord/message.hpp +++ b/discord/message.hpp @@ -27,7 +27,7 @@ enum class MessageType { GUILD_DISCOVERY_REQUALIFIED = 15, // yep GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING = 16, // yep GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING = 17, // yep - THREAD_CREATED = 18, // nope + THREAD_CREATED = 18, // yep INLINE_REPLY = 19, // yep APPLICATION_COMMAND = 20, // yep THREAD_STARTER_MESSAGE = 21, // nope -- cgit v1.2.3