core: handleMode: Fix persistent modes reset
authorgenius3000 <genius3000@g3k.solutions>
Thu, 11 Jan 2018 04:54:41 +0000 (21:54 -0700)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 1 May 2018 20:25:31 +0000 (22:25 +0200)
The check for '-reset' currently comes after a bufferName is
prepended to params, therefore never being true.
Move this check to be first and add a reply to the client.

Closes GH-322.

src/core/coreuserinputhandler.cpp

index c30a2fa..8878340 100644 (file)
@@ -476,15 +476,16 @@ void CoreUserInputHandler::handleMode(const BufferInfo &bufferInfo, const QStrin
     QStringList params = msg.split(' ', QString::SkipEmptyParts);
     // if the first argument is neither a channel nor us (user modes are only to oneself) the current buffer is assumed to be the target
     if (!params.isEmpty()) {
     QStringList params = msg.split(' ', QString::SkipEmptyParts);
     // if the first argument is neither a channel nor us (user modes are only to oneself) the current buffer is assumed to be the target
     if (!params.isEmpty()) {
-        if (!network()->isChannelName(params[0]) && !network()->isMyNick(params[0]))
-            params.prepend(bufferInfo.bufferName());
-        if (network()->isMyNick(params[0]) && params.count() == 2)
-            network()->updateIssuedModes(params[1]);
         if (params[0] == "-reset" && params.count() == 1) {
         if (params[0] == "-reset" && params.count() == 1) {
-            // FIXME: give feedback to the user (I don't want to add new strings right now)
             network()->resetPersistentModes();
             network()->resetPersistentModes();
+            emit displayMsg(Message::Info, BufferInfo::StatusBuffer, "",
+                            tr("Your persistent modes have been reset."));
             return;
         }
             return;
         }
+        if (!network()->isChannelName(params[0]) && !network()->isMyNick(params[0]))
+            params.prepend(bufferInfo.bufferName());
+        if (network()->isMyNick(params[0]) && params.count() == 2)
+            network()->updateIssuedModes(params[1]);
     }
 
     // TODO handle correct encoding for buffer modes (channelEncode())
     }
 
     // TODO handle correct encoding for buffer modes (channelEncode())