diff --git a/src/components/channels.cpp b/src/components/channels.cpp index 4d3d5a2..d8fbde9 100644 --- a/src/components/channels.cpp +++ b/src/components/channels.cpp @@ -701,6 +701,11 @@ void ChannelList::OnMessageAck(const MessageAckData &data) { // trick renderer into redrawing auto iter = GetIteratorForChannelFromID(data.ChannelID); if (iter) m_model->row_changed(m_model->get_path(iter), iter); + auto channel = Abaddon::Get().GetDiscordClient().GetChannel(data.ChannelID); + if (channel.has_value() && channel->GuildID.has_value()) { + iter = GetIteratorForGuildFromID(*channel->GuildID); + if (iter) m_model->row_changed(m_model->get_path(iter), iter); + } } void ChannelList::OnMessageCreate(const Message &msg) { diff --git a/src/components/channelscellrenderer.cpp b/src/components/channelscellrenderer.cpp index f4cd33c..a96668c 100644 --- a/src/components/channelscellrenderer.cpp +++ b/src/components/channelscellrenderer.cpp @@ -198,7 +198,7 @@ void CellRendererChannels::render_vfunc_guild(const Cairo::RefPtrrectangle(icon_x, icon_y, icon_w, icon_h); cr->fill(); } + + UnreadRenderer::RenderUnreadOnGuild(m_property_id.get_value(), cr, background_area, cell_area); } // category diff --git a/src/components/unreadrenderer.cpp b/src/components/unreadrenderer.cpp index 4e508fc..b53af2d 100644 --- a/src/components/unreadrenderer.cpp +++ b/src/components/unreadrenderer.cpp @@ -1,14 +1,36 @@ #include "unreadrenderer.hpp" #include "abaddon.hpp" +void UnreadRenderer::RenderUnreadOnGuild(Snowflake id, const Cairo::RefPtr &cr, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area) { + // maybe have DiscordClient track this? + auto &discord = Abaddon::Get().GetDiscordClient(); + const auto channels = discord.GetChannelsInGuild(id); + bool has_unread = false; + for (const auto &id : channels) { + if (Abaddon::Get().GetDiscordClient().GetUnreadStateForChannel(id) >= 0) { + has_unread = true; + break; + } + } + if (!has_unread) return; + + cr->set_source_rgb(1.0, 1.0, 1.0); + const auto x = background_area.get_x(); + const auto y = background_area.get_y(); + const auto w = background_area.get_width(); + const auto h = background_area.get_height(); + cr->rectangle(x, y + h / 2 - 24 / 2, 3, 24); + cr->fill(); +} + void UnreadRenderer::RenderUnreadOnChannel(Snowflake id, const Cairo::RefPtr &cr, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area) { const auto state = Abaddon::Get().GetDiscordClient().GetUnreadStateForChannel(id); if (state >= 0) { cr->set_source_rgb(1.0, 1.0, 1.0); - const auto x = cell_area.get_x() + 1; - const auto y = cell_area.get_y(); - const auto w = cell_area.get_width(); - const auto h = cell_area.get_height(); + const auto x = background_area.get_x(); + const auto y = background_area.get_y(); + const auto w = background_area.get_width(); + const auto h = background_area.get_height(); cr->rectangle(x, y, 3, h); cr->fill(); } diff --git a/src/components/unreadrenderer.hpp b/src/components/unreadrenderer.hpp index e333543..30446fa 100644 --- a/src/components/unreadrenderer.hpp +++ b/src/components/unreadrenderer.hpp @@ -5,5 +5,6 @@ class UnreadRenderer { public: + static void RenderUnreadOnGuild(Snowflake id, const Cairo::RefPtr &cr, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area); static void RenderUnreadOnChannel(Snowflake id, const Cairo::RefPtr &cr, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area); };