mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:17:45 +00:00
IRCClient: Only notify about channel messages containing our nickname
This commit is contained in:
parent
163812df97
commit
3c29818048
2 changed files with 30 additions and 17 deletions
|
@ -93,25 +93,36 @@ bool IRCWindow::is_active() const
|
||||||
return m_client.current_window() == this;
|
return m_client.current_window() == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IRCWindow::post_notification_if_needed(const String& name, const String& message)
|
||||||
|
{
|
||||||
|
if (name.is_null() || message.is_null())
|
||||||
|
return;
|
||||||
|
if (is_active() && window()->is_active())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto notification = GUI::Notification::construct();
|
||||||
|
|
||||||
|
if (type() == Type::Channel) {
|
||||||
|
|
||||||
|
if (!message.contains(m_client.nickname()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
StringBuilder builder;
|
||||||
|
builder.append(name);
|
||||||
|
builder.append(" in ");
|
||||||
|
builder.append(m_name);
|
||||||
|
notification->set_title(builder.to_string());
|
||||||
|
} else {
|
||||||
|
notification->set_title(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
notification->set_text(message);
|
||||||
|
notification->show();
|
||||||
|
}
|
||||||
|
|
||||||
void IRCWindow::did_add_message(const String& name, const String& message)
|
void IRCWindow::did_add_message(const String& name, const String& message)
|
||||||
{
|
{
|
||||||
if ((!is_active() || !window()->is_active()) && !name.is_null() && !message.is_null()) {
|
post_notification_if_needed(name, message);
|
||||||
auto notification = GUI::Notification::construct();
|
|
||||||
|
|
||||||
if (type() == Type::Channel) {
|
|
||||||
StringBuilder builder;
|
|
||||||
builder.append(name);
|
|
||||||
builder.append(" in ");
|
|
||||||
builder.append(m_name);
|
|
||||||
notification->set_title(builder.to_string());
|
|
||||||
} else {
|
|
||||||
notification->set_title(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
notification->set_title(name);
|
|
||||||
notification->set_text(message);
|
|
||||||
notification->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_active()) {
|
if (!is_active()) {
|
||||||
++m_unread_count;
|
++m_unread_count;
|
||||||
|
|
|
@ -68,6 +68,8 @@ public:
|
||||||
private:
|
private:
|
||||||
IRCWindow(IRCClient&, void* owner, Type, const String& name);
|
IRCWindow(IRCClient&, void* owner, Type, const String& name);
|
||||||
|
|
||||||
|
void post_notification_if_needed(const String& name, const String& message);
|
||||||
|
|
||||||
IRCClient& m_client;
|
IRCClient& m_client;
|
||||||
void* m_owner { nullptr };
|
void* m_owner { nullptr };
|
||||||
Type m_type;
|
Type m_type;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue