From c154a63967264c5a22e5b4e4d4e7dfd83e265b9c Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 4 Jul 2021 02:21:32 -0400 Subject: [PATCH] update guild --- components/channels.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/channels.cpp b/components/channels.cpp index 80c321c..5746259 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -159,6 +159,22 @@ void ChannelList::UpdateCreateChannel(Snowflake id) { } void ChannelList::UpdateGuild(Snowflake id) { + auto iter = GetIteratorForGuildFromID(id); + auto &img = Abaddon::Get().GetImageManager(); + const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(id); + if (!iter || !guild.has_value()) return; + + (*iter)[m_columns.m_name] = "" + Glib::Markup::escape_text(guild->Name) + ""; + (*iter)[m_columns.m_icon] = img.GetPlaceholder(24); + if (guild->HasIcon()) { + const auto cb = [this, id](const Glib::RefPtr &pb) { + // iter might be invalid + auto iter = GetIteratorForGuildFromID(id); + if (iter) + (*iter)[m_columns.m_icon] = pb->scale_simple(24, 24, Gdk::INTERP_BILINEAR); + }; + img.LoadFromURL(guild->GetIconURL("png", "32"), sigc::track_obj(cb, *this)); + } } void ChannelList::SetActiveChannel(Snowflake id) {