From 15954830e278007fc8da209944d4422240d65ecc Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 10 Dec 2021 03:26:33 -0500 Subject: hide guild unread indicator for muted guilds --- src/discord/discord.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/discord/discord.cpp') diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index f21946f..af25b3a 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::IsGuildMuted(Snowflake id) const noexcept { + return m_muted_guilds.find(id) != m_muted_guilds.end(); +} + int DiscordClient::GetUnreadStateForChannel(Snowflake id) const noexcept { const auto iter = m_unread.find(id); if (iter == m_unread.end()) return -1; // todo: no magic number @@ -1457,6 +1461,7 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) { m_user_settings = data.Settings; HandleReadyReadState(data); + HandleReadyGuildSettings(data); m_signal_gateway_ready.emit(); } @@ -2181,6 +2186,13 @@ void DiscordClient::HandleReadyReadState(const ReadyEventData &data) { } } +void DiscordClient::HandleReadyGuildSettings(const ReadyEventData &data) { + for (const auto &entry : data.GuildSettings.Entries) { + if (entry.Muted) + m_muted_guilds.insert(entry.GuildID); + } +} + void DiscordClient::LoadEventMap() { m_event_map["READY"] = GatewayEvent::READY; m_event_map["MESSAGE_CREATE"] = GatewayEvent::MESSAGE_CREATE; -- cgit v1.2.3