summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-03 21:47:43 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-03 21:47:43 +0200
commit9cb4e5ac814fdedb7c1b34ff8c61b4165b5e6bc6 (patch)
tree4f581a7d977eb91f98fe4a3ac87892afba945ef0 /Applications
parent5c7ef5977d7c867069a8b2d320a3ebb99fe7c658 (diff)
downloadserenity-9cb4e5ac814fdedb7c1b34ff8c61b4165b5e6bc6.zip
IRCClient: Don't auto-open new queries for NOTICE or CTCP messages
This seems to match what other IRC clients do, and it means we don't get three separate "server" windows when connecting to Freenode. :^)
Diffstat (limited to 'Applications')
-rw-r--r--Applications/IRCClient/IRCClient.cpp25
-rw-r--r--Applications/IRCClient/IRCClient.h3
2 files changed, 23 insertions, 5 deletions
diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp
index 2b93fba7c3..f0442a726e 100644
--- a/Applications/IRCClient/IRCClient.cpp
+++ b/Applications/IRCClient/IRCClient.cpp
@@ -281,9 +281,9 @@ void IRCClient::handle(const Message& msg)
add_server_message(String::format("[%s] %s", msg.command.characters(), msg.arguments[1].characters()));
}
-void IRCClient::add_server_message(const String& text)
+void IRCClient::add_server_message(const String& text, Color color)
{
- m_log->add_message(0, "", text);
+ m_log->add_message(0, "", text, color);
m_server_subwindow->did_add_message();
}
@@ -393,8 +393,25 @@ void IRCClient::handle_privmsg_or_notice(const Message& msg, PrivmsgOrNotice typ
return;
}
}
- auto& query = ensure_query(sender_nick);
- query.add_message(sender_prefix, sender_nick, message_text, message_color);
+
+ // For NOTICE or CTCP messages, only put them in query if one already exists.
+ // Otherwise, put them in the server window. This seems to match other clients.
+ IRCQuery* query = nullptr;
+ if (is_ctcp || type == PrivmsgOrNotice::Notice) {
+ query = query_with_name(sender_nick);
+ } else {
+ query = &ensure_query(sender_nick);
+ }
+ if (query)
+ query->add_message(sender_prefix, sender_nick, message_text, message_color);
+ else {
+ add_server_message(String::format("<%s> %s", sender_nick.characters(), message_text.characters()), message_color);
+ }
+}
+
+IRCQuery* IRCClient::query_with_name(const String& name)
+{
+ return m_queries.get(name).value_or(nullptr);
}
IRCQuery& IRCClient::ensure_query(const String& name)
diff --git a/Applications/IRCClient/IRCClient.h b/Applications/IRCClient/IRCClient.h
index 02891a09ff..820229e71d 100644
--- a/Applications/IRCClient/IRCClient.h
+++ b/Applications/IRCClient/IRCClient.h
@@ -82,10 +82,11 @@ public:
void handle_part_action(const String&);
void handle_change_nick_action(const String&);
+ IRCQuery* query_with_name(const String&);
IRCQuery& ensure_query(const String& name);
IRCChannel& ensure_channel(const String& name);
- void add_server_message(const String&);
+ void add_server_message(const String&, Color = Color::Black);
private:
struct Message {