diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-12-16 00:58:17 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-12-16 00:58:17 -0500 |
commit | 1fb7ca000753d2c6a39a560126f3ba7d229af46d (patch) | |
tree | 8a7fe60438c2f58b2461a4f001fbae975e9f7f11 /src | |
parent | a5332efcfb411bb8ed04d569e20f77996eb1aa6c (diff) | |
download | abaddon-portaudio-1fb7ca000753d2c6a39a560126f3ba7d229af46d.tar.gz abaddon-portaudio-1fb7ca000753d2c6a39a560126f3ba7d229af46d.zip |
hide unread indicator for muted channels
Diffstat (limited to 'src')
-rw-r--r-- | src/components/unreadrenderer.cpp | 23 | ||||
-rw-r--r-- | src/discord/discord.cpp | 8 | ||||
-rw-r--r-- | src/discord/discord.hpp | 2 |
3 files changed, 23 insertions, 10 deletions
diff --git a/src/components/unreadrenderer.cpp b/src/components/unreadrenderer.cpp index b2d3262..c49b8c3 100644 --- a/src/components/unreadrenderer.cpp +++ b/src/components/unreadrenderer.cpp @@ -32,7 +32,7 @@ void RenderMentionsCount(const Cairo::RefPtr<Cairo::Context> &cr, Gtk::Widget &w layout->get_pixel_size(width, height); { const auto x = cell_area.get_x() + edge - width - MentionsRightPad; - const auto y = cell_area.get_y() + cell_area.get_height() / 2.0 - height / 2.0; + const auto y = cell_area.get_y() + cell_area.get_height() / 2.0 - height / 2.0 - 1; CairoPathRoundedRect(cr, x - 4, y + 2, width + 8, height, 5); cr->set_source_rgb(184.0 / 255.0, 37.0 / 255.0, 37.0 / 255.0); cr->fill(); @@ -70,22 +70,25 @@ void UnreadRenderer::RenderUnreadOnGuild(Snowflake id, Gtk::Widget &widget, cons if (total_mentions < 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()); + const auto edge = std::min(paned->get_position(), background_area.get_width()); - RenderMentionsCount(cr, widget, total_mentions, edge, cell_area); + RenderMentionsCount(cr, widget, total_mentions, edge, background_area); } } void UnreadRenderer::RenderUnreadOnChannel(Snowflake id, Gtk::Widget &widget, const Cairo::RefPtr<Cairo::Context> &cr, const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area) { const auto state = Abaddon::Get().GetDiscordClient().GetUnreadStateForChannel(id); if (state < 0) 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, 3, h); - cr->fill(); + + if (!Abaddon::Get().GetDiscordClient().IsChannelMuted(id)) { + 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 (state < 1) return; auto *paned = static_cast<Gtk::Paned *>(widget.get_ancestor(Gtk::Paned::get_type())); diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index af25b3a..b54064a 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -1095,6 +1095,10 @@ void DiscordClient::SetUserAgent(std::string agent) { m_websocket.SetUserAgent(agent); } +bool DiscordClient::IsChannelMuted(Snowflake id) const noexcept { + return m_muted_channels.find(id) != m_muted_channels.end(); +} + bool DiscordClient::IsGuildMuted(Snowflake id) const noexcept { return m_muted_guilds.find(id) != m_muted_guilds.end(); } @@ -2190,6 +2194,10 @@ void DiscordClient::HandleReadyGuildSettings(const ReadyEventData &data) { for (const auto &entry : data.GuildSettings.Entries) { if (entry.Muted) m_muted_guilds.insert(entry.GuildID); + for (const auto &override : entry.ChannelOverrides) { + if (override.Muted) + m_muted_channels.insert(override.ChannelID); + } } } diff --git a/src/discord/discord.hpp b/src/discord/discord.hpp index 4dc9520..fbee775 100644 --- a/src/discord/discord.hpp +++ b/src/discord/discord.hpp @@ -184,6 +184,7 @@ public: void UpdateToken(std::string token); void SetUserAgent(std::string agent); + bool IsChannelMuted(Snowflake id) const noexcept; bool IsGuildMuted(Snowflake id) const noexcept; int GetUnreadStateForChannel(Snowflake id) const noexcept; @@ -280,6 +281,7 @@ private: std::map<Snowflake, std::vector<Snowflake>> m_thread_members; std::map<Snowflake, Snowflake> m_last_message_id; std::unordered_set<Snowflake> m_muted_guilds; + std::unordered_set<Snowflake> m_muted_channels; std::unordered_map<Snowflake, int> m_unread; UserData m_user_data; |