summaryrefslogtreecommitdiff
path: root/src/discord/discord.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-12-25 03:07:11 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2021-12-25 03:07:11 -0500
commit207c00422861c91c553654a37c52e21f72c76cc2 (patch)
tree2cdb80fe62e54fd51fce29508800003d1df5bf26 /src/discord/discord.cpp
parent36f73a6106a17463724e44fb5580dc2ee96d06ba (diff)
downloadabaddon-portaudio-207c00422861c91c553654a37c52e21f72c76cc2.tar.gz
abaddon-portaudio-207c00422861c91c553654a37c52e21f72c76cc2.zip
take muted channels into account for unread guild indicator
Diffstat (limited to 'src/discord/discord.cpp')
-rw-r--r--src/discord/discord.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp
index 5443b87..eac6428 100644
--- a/src/discord/discord.cpp
+++ b/src/discord/discord.cpp
@@ -1156,10 +1156,24 @@ bool DiscordClient::IsGuildMuted(Snowflake id) const noexcept {
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
+ if (iter == m_unread.end()) return -1; // todo: no magic number (who am i kidding ill never change this)
return iter->second;
}
+bool DiscordClient::GetUnreadStateForGuild(Snowflake id, int &total_mentions) const noexcept {
+ total_mentions = 0;
+ bool has_any_unread = false;
+ const auto channels = GetChannelsInGuild(id);
+ for (const auto channel_id : channels) {
+ const auto channel_unread = GetUnreadStateForChannel(channel_id);
+ if (!has_any_unread && channel_unread > -1 && !IsChannelMuted(channel_id))
+ has_any_unread = true;
+ if (channel_unread > -1)
+ total_mentions += channel_unread;
+ }
+ return has_any_unread;
+}
+
PresenceStatus DiscordClient::GetUserStatus(Snowflake id) const {
auto it = m_user_to_status.find(id);
if (it != m_user_to_status.end())