dont notify if message channel is focused

This commit is contained in:
ouwou
2023-03-01 01:01:44 -05:00
parent e37901bbbb
commit a09ad5cec0
3 changed files with 12 additions and 0 deletions

View File

@@ -696,6 +696,14 @@ Glib::RefPtr<Gtk::Application> Abaddon::GetApp() {
return m_gtk_app;
}
bool Abaddon::IsMainWindowActive() {
return m_main_window->has_toplevel_focus();
}
Snowflake Abaddon::GetActiveChannelID() const noexcept {
return m_main_window->GetChatActiveChannel();
}
void Abaddon::ActionConnect() {
if (!m_discord.IsStarted())
StartDiscord();

View File

@@ -97,6 +97,8 @@ public:
static std::string GetStateCachePath(const std::string &path);
[[nodiscard]] Glib::RefPtr<Gtk::Application> GetApp();
[[nodiscard]] bool IsMainWindowActive();
[[nodiscard]] Snowflake GetActiveChannelID() const noexcept;
protected:
void RunFirstTimeDiscordStartup();

View File

@@ -10,6 +10,8 @@ void Notifications::CheckMessage(const Message &message) {
auto &discord = Abaddon::Get().GetDiscordClient();
// ignore if the channel is muted
if (discord.IsChannelMuted(message.ChannelID)) return;
// ignore if focused and message's channel is active
if (Abaddon::Get().IsMainWindowActive() && Abaddon::Get().GetActiveChannelID() == message.ChannelID) return;
// notify messages in DMs
const auto channel = discord.GetChannel(message.ChannelID);
if (channel->IsDM()) {