Join current channel if no name is given
authorNicolas Cornu <nicolac76@yahoo.fr>
Thu, 20 May 2021 09:45:23 +0000 (11:45 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 13 Jun 2021 13:44:14 +0000 (15:44 +0200)
If user type `/join` on a channel without name it will take the name of
the current channel

src/client/clientuserinputhandler.cpp

index dc21d28..6528737 100644 (file)
@@ -91,13 +91,18 @@ void ClientUserInputHandler::handleExec(const BufferInfo& bufferInfo, const QStr
 
 void ClientUserInputHandler::handleJoin(const BufferInfo& bufferInfo, const QString& text)
 {
-    if (text.isEmpty()) {
-        Client::messageModel()->insertErrorMessage(bufferInfo, tr("/JOIN expects a channel"));
-        return;
+    auto channelName = text;
+    if (channelName.isEmpty()) {
+        if (bufferInfo.type() == BufferInfo::ChannelBuffer) {
+            channelName = bufferInfo.bufferName();
+        } else {
+            Client::messageModel()->insertErrorMessage(bufferInfo, tr("/JOIN expects a channel"));
+            return;
+        }
     }
-    switchBuffer(bufferInfo.networkId(), text.section(' ', 0, 0));
+    switchBuffer(bufferInfo.networkId(), channelName.section(' ', 0, 0));
     // send to core
-    defaultHandler("JOIN", bufferInfo, text);
+    defaultHandler("JOIN", bufferInfo, channelName);
 }
 
 void ClientUserInputHandler::handleQuery(const BufferInfo& bufferInfo, const QString& text)