dont notify if message channel is focused
This commit is contained in:
@@ -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();
|
||||
|
@@ -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();
|
||||
|
@@ -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()) {
|
||||
|
Reference in New Issue
Block a user