diff --git a/CHANGELOG.md b/CHANGELOG.md index 62957f79..0150f049 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - Dev: Save settings in `aboutToQuit`. (#6159) - Dev: Bumped deprecation cutoff to Qt 6.4.3. (#6169) - Dev: Updated GoogleTest to v1.17.0. (#6180) +- Dev: Mini refactor of `TwitchAccount`. (#6182) - Dev: Simplified string literals to be a re-export of Qt functions. (#6175) ## 2.5.3 diff --git a/src/common/Aliases.hpp b/src/common/Aliases.hpp index b524fc0d..aa5debf9 100644 --- a/src/common/Aliases.hpp +++ b/src/common/Aliases.hpp @@ -1,9 +1,10 @@ #pragma once #include -#include +#include #include +#include #include // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index 586cbd06..1c8e14ca 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -2,33 +2,27 @@ #include "Application.hpp" #include "common/Channel.hpp" -#include "common/Env.hpp" -#include "common/Literals.hpp" -#include "common/network/NetworkResult.hpp" +#include "common/network/NetworkResult.hpp" // IWYU pragma: keep #include "common/QLogging.hpp" #include "controllers/accounts/AccountController.hpp" #include "debug/AssertInGuiThread.hpp" #include "messages/Emote.hpp" -#include "messages/Message.hpp" #include "messages/MessageBuilder.hpp" -#include "providers/IvrApi.hpp" #include "providers/seventv/SeventvAPI.hpp" #include "providers/twitch/api/Helix.hpp" #include "providers/twitch/TwitchCommon.hpp" #include "providers/twitch/TwitchUsers.hpp" #include "singletons/Emotes.hpp" #include "util/CancellationToken.hpp" -#include "util/Helpers.hpp" -#include "util/QStringHash.hpp" -#include "util/RapidjsonHelpers.hpp" +#include "util/QStringHash.hpp" // IWYU pragma: keep #include #include #include -namespace chatterino { +using namespace Qt::Literals::StringLiterals; -using namespace literals; +namespace chatterino { TwitchAccount::TwitchAccount(const QString &username, const QString &oauthToken, const QString &oauthClient, const QString &userID) @@ -215,7 +209,7 @@ const std::unordered_set &TwitchAccount::blockedUserLogins() const } // AutoModActions -void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel) +void TwitchAccount::autoModAllow(const QString &msgID, ChannelPtr channel) const { getHelix()->manageAutoModMessages( this->getUserId(), msgID, "ALLOW", @@ -252,7 +246,7 @@ void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel) // This would most likely happen if the service is down, or if the JSON payload returned has changed format case HelixAutoModMessageError::Unknown: default: { - errorMessage += "an unknown error occured."; + errorMessage += "an unknown error occurred."; } break; } @@ -261,7 +255,7 @@ void TwitchAccount::autoModAllow(const QString msgID, ChannelPtr channel) }); } -void TwitchAccount::autoModDeny(const QString msgID, ChannelPtr channel) +void TwitchAccount::autoModDeny(const QString &msgID, ChannelPtr channel) const { getHelix()->manageAutoModMessages( this->getUserId(), msgID, "DENY", @@ -298,7 +292,7 @@ void TwitchAccount::autoModDeny(const QString msgID, ChannelPtr channel) // This would most likely happen if the service is down, or if the JSON payload returned has changed format case HelixAutoModMessageError::Unknown: default: { - errorMessage += "an unknown error occured."; + errorMessage += "an unknown error occurred."; } break; } diff --git a/src/providers/twitch/TwitchAccount.hpp b/src/providers/twitch/TwitchAccount.hpp index cd0901fb..79c3ef76 100644 --- a/src/providers/twitch/TwitchAccount.hpp +++ b/src/providers/twitch/TwitchAccount.hpp @@ -1,5 +1,6 @@ #pragma once +#include "common/Aliases.hpp" #include "common/Atomic.hpp" #include "common/UniqueAccess.hpp" #include "controllers/accounts/Account.hpp" @@ -7,18 +8,17 @@ #include "providers/twitch/TwitchEmotes.hpp" #include "providers/twitch/TwitchUser.hpp" #include "util/CancellationToken.hpp" -#include "util/QStringHash.hpp" -#include #include #include #include #include #include -#include +#include #include -#include +#include +#include #include namespace chatterino { @@ -78,8 +78,8 @@ public: [[nodiscard]] const std::unordered_set &blockedUserLogins() const; // Automod actions - void autoModAllow(const QString msgID, ChannelPtr channel); - void autoModDeny(const QString msgID, ChannelPtr channel); + void autoModAllow(const QString &msgID, ChannelPtr channel) const; + void autoModDeny(const QString &msgID, ChannelPtr channel) const; void loadSeventvUserID();