summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-01-20 01:34:36 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2022-01-20 01:34:36 -0500
commitdfd642bb82d2998cc563f0f401f2d522632692c1 (patch)
treef17f49dbe7d6faf5ea1687206efee6b1a47d8b55
parent6c9bf4ff81a588ba8c4fb1713217d699eba057c4 (diff)
downloadabaddon-portaudio-dfd642bb82d2998cc563f0f401f2d522632692c1.tar.gz
abaddon-portaudio-dfd642bb82d2998cc563f0f401f2d522632692c1.zip
show unread indicators for threads
-rw-r--r--src/components/channelscellrenderer.cpp32
-rw-r--r--src/discord/discord.cpp6
2 files changed, 37 insertions, 1 deletions
diff --git a/src/components/channelscellrenderer.cpp b/src/components/channelscellrenderer.cpp
index 4578020..fa7880f 100644
--- a/src/components/channelscellrenderer.cpp
+++ b/src/components/channelscellrenderer.cpp
@@ -438,7 +438,39 @@ void CellRendererChannels::render_vfunc_thread(const Cairo::RefPtr<Cairo::Contex
const int text_h = natural_size.height;
Gdk::Rectangle text_cell_area(text_x, text_y, text_w, text_h);
+
+ auto &discord = Abaddon::Get().GetDiscordClient();
+ const auto id = m_property_id.get_value();
+ const bool is_muted = discord.IsChannelMuted(id);
+
+ static Gdk::RGBA muted_color("#7f7f7f");
+ if (discord.IsChannelMuted(m_property_id.get_value()))
+ m_renderer_text.property_foreground_rgba() = muted_color;
m_renderer_text.render(cr, widget, background_area, text_cell_area, flags);
+ m_renderer_text.property_foreground_set() = false;
+
+ // unread
+
+ const auto unread_state = discord.GetUnreadStateForChannel(id);
+ if (unread_state < 0) return;
+
+ if (!is_muted) {
+ 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, 3, h);
+ cr->fill();
+ }
+
+ if (unread_state < 1) return;
+ auto *paned = static_cast<Gtk::Paned *>(widget.get_ancestor(Gtk::Paned::get_type()));
+ if (paned != nullptr) {
+ const auto edge = std::min(paned->get_position(), cell_area.get_width());
+
+ unread_render_mentions(cr, widget, unread_state, edge, cell_area);
+ }
}
// dm header
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp
index 5b3cdb5..ff269df 100644
--- a/src/discord/discord.cpp
+++ b/src/discord/discord.cpp
@@ -2343,10 +2343,14 @@ void DiscordClient::StoreMessageData(Message &msg) {
// here the absence of an entry in m_unread indicates a read channel and the value is only the mention count since the message doesnt matter
// no entry.id cannot be a guild even though sometimes it looks like it
void DiscordClient::HandleReadyReadState(const ReadyEventData &data) {
- for (const auto &guild : data.Guilds)
+ for (const auto &guild : data.Guilds) {
for (const auto &channel : *guild.Channels)
if (channel.LastMessageID.has_value())
m_last_message_id[channel.ID] = *channel.LastMessageID;
+ for (const auto &thread : *guild.Threads)
+ if (thread.LastMessageID.has_value())
+ m_last_message_id[thread.ID] = *thread.LastMessageID;
+ }
for (const auto &channel : data.PrivateChannels)
if (channel.LastMessageID.has_value())
m_last_message_id[channel.ID] = *channel.LastMessageID;