From cd8247f9218a5557e74aa3dcff761ba975d2ae41 Mon Sep 17 00:00:00 2001 From: nerix Date: Mon, 3 Mar 2025 13:30:11 +0100 Subject: [PATCH] chore: remove dead code and get rid of MSVC warnings (#6024) --- CHANGELOG.md | 1 + src/common/Channel.cpp | 9 ++---- src/common/Channel.hpp | 4 +-- .../builtin/twitch/DeleteMessages.cpp | 4 +-- src/providers/twitch/IrcMessageHandler.cpp | 2 +- src/widgets/dialogs/UserInfoPopup.cpp | 4 +-- src/widgets/splits/SplitInput.cpp | 31 +------------------ 7 files changed, 9 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b55aec7..f8d750ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - Dev: BTTV emotes are now loaded as WEBP. (#5957) - Dev: Reduced time we wait for PubSub connections to cleanly exit from 1s to 100ms. (#6019) - Dev: Added snapshot tests for EventSub. (#5965) +- Dev: Removed dead code and some MSVC warnings. (#6024) ## 2.5.2 diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index e492ece4..12593775 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -283,9 +283,9 @@ void Channel::replaceMessage(size_t hint, const MessagePtr &message, } } -void Channel::disableMessage(QString messageID) +void Channel::disableMessage(const QString &messageID) { - auto msg = this->findMessage(messageID); + auto msg = this->findMessageByID(messageID); if (msg != nullptr) { msg->flags.set(MessageFlag::Disabled); @@ -298,11 +298,6 @@ void Channel::clearMessages() this->messagesCleared.invoke(); } -MessagePtr Channel::findMessage(QString messageID) -{ - return this->findMessageByID(messageID); -} - MessagePtr Channel::findMessageByID(QStringView messageID) { MessagePtr res; diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index c2655cbc..7956af78 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -99,13 +99,11 @@ public: void replaceMessage(size_t index, const MessagePtr &replacement); void replaceMessage(size_t hint, const MessagePtr &message, const MessagePtr &replacement); - void disableMessage(QString messageID); + void disableMessage(const QString &messageID); /// Removes all messages from this channel and invokes #messagesCleared void clearMessages(); - [[deprecated("Use findMessageByID instead")]] MessagePtr findMessage( - QString messageID); MessagePtr findMessageByID(QStringView messageID) final; bool hasMessages() const; diff --git a/src/controllers/commands/builtin/twitch/DeleteMessages.cpp b/src/controllers/commands/builtin/twitch/DeleteMessages.cpp index c79e558c..3e283da1 100644 --- a/src/controllers/commands/builtin/twitch/DeleteMessages.cpp +++ b/src/controllers/commands/builtin/twitch/DeleteMessages.cpp @@ -2,12 +2,10 @@ #include "Application.hpp" #include "common/Channel.hpp" -#include "common/network/NetworkResult.hpp" #include "controllers/accounts/AccountController.hpp" #include "controllers/commands/CommandContext.hpp" #include "messages/Message.hpp" #include "messages/MessageBuilder.hpp" -#include "providers/twitch/api/Helix.hpp" #include "providers/twitch/TwitchAccount.hpp" #include "providers/twitch/TwitchChannel.hpp" @@ -91,7 +89,7 @@ QString deleteOneMessage(const CommandContext &ctx) return ""; } - auto msg = ctx.channel->findMessage(messageID); + auto msg = ctx.channel->findMessageByID(messageID); if (msg != nullptr) { if (msg->loginName == ctx.channel->getName() && diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index 54c8b162..598dcaee 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -512,7 +512,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message) QString targetID = tags.value("target-msg-id").toString(); - auto msg = chan->findMessage(targetID); + auto msg = chan->findMessageByID(targetID); if (msg == nullptr) { return; diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 7635021b..6480d5f7 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -924,9 +924,9 @@ void UserInfoPopup::updateUserData() // get ignoreHighlights state bool isIgnoringHighlights = false; const auto &vector = getSettings()->blacklistedUsers.raw(); - for (const auto &user : vector) + for (const auto &blockedUser : vector) { - if (this->userName_ == user.getPattern()) + if (this->userName_ == blockedUser.getPattern()) { isIgnoringHighlights = true; break; diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 05aa4978..10ea3811 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -372,36 +372,7 @@ QString SplitInput::handleSendMessage(const std::vector &arguments) auto *tc = dynamic_cast(c.get()); if (!tc) { - // Reply to message - auto tc = dynamic_cast(c.get()); - if (!tc) - { - // this should not fail - return ""; - } - - QString message = this->ui_.textEdit->toPlainText(); - - if (this->enableInlineReplying_) - { - // Remove @username prefix that is inserted when doing inline replies - message.remove(0, this->replyTarget_->displayName.length() + - 1); // remove "@username" - - if (!message.isEmpty() && message.at(0) == ' ') - { - message.remove(0, 1); // remove possible space - } - } - - message = message.replace('\n', ' '); - QString sendMessage = - getApp()->getCommands()->execCommand(message, c, false); - - // Reply within TwitchChannel - tc->sendReply(sendMessage, this->replyTarget_->id); - - this->postMessageSend(message, arguments); + // this should not fail return ""; }