diff --git a/CHANGELOG.md b/CHANGELOG.md
index 79fccb7e..71f01ebe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,6 +44,7 @@
- Bugfix: Fixed CMD + DELETE behavior in the user notes editing dialog for macOS. (#6676)
- Bugfix: Fixed a potential crash when closing Chatterino with a slow network connection. (#6645)
- Bugfix: Disable "Sort Tabs Alphabetically" action when notebook layout is locked. (#6710)
+- Bugfix: Fix highlight mentions not updating when username changes. (#6723)
- Bugfix: Fixed Return and Enter being treated as different keys on Mac OS. (#6726)
- Dev: Update release documentation. (#6498)
- Dev: Make code sanitizers opt in with the `CHATTERINO_SANITIZER_SUPPORT` CMake option. After that's enabled, use the `SANITIZE_*` flag to enable individual sanitizers. (#6493)
diff --git a/src/controllers/highlights/HighlightController.cpp b/src/controllers/highlights/HighlightController.cpp
index 07c45b62..e41ef85b 100644
--- a/src/controllers/highlights/HighlightController.cpp
+++ b/src/controllers/highlights/HighlightController.cpp
@@ -441,6 +441,12 @@ HighlightController::HighlightController(Settings &settings,
this->rebuildChecks(settings);
}));
+ this->signalHolder_.managedConnect(
+ accounts->twitch.currentUserNameChanged, [this, &settings] {
+ qCDebug(chatterinoHighlights)
+ << "Rebuild checks because user name changed";
+ this->rebuildChecks(settings);
+ });
this->rebuildChecks(settings);
}
diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp
index 932d1a76..18bfbfa7 100644
--- a/src/providers/twitch/TwitchAccount.cpp
+++ b/src/providers/twitch/TwitchAccount.cpp
@@ -194,6 +194,16 @@ void TwitchAccount::blockUserLocally(const QString &userID,
this->ignoresUserLogins_.insert(blockedUser.name);
}
+bool TwitchAccount::setUserName(const QString &newUserName)
+{
+ if (this->userName_.compare(newUserName, Qt::CaseInsensitive) == 0)
+ {
+ return false;
+ }
+ this->userName_ = newUserName;
+ return true;
+}
+
const std::unordered_set &TwitchAccount::blocks() const
{
assertInGuiThread();
diff --git a/src/providers/twitch/TwitchAccount.hpp b/src/providers/twitch/TwitchAccount.hpp
index 66ba1eb5..61832000 100644
--- a/src/providers/twitch/TwitchAccount.hpp
+++ b/src/providers/twitch/TwitchAccount.hpp
@@ -65,6 +65,10 @@ public:
// Returns true if the value has changed, otherwise false
bool setOAuthToken(const QString &newOAuthToken);
+ // Attempts to update the users username
+ // Returns true if the value has changed, otherwise false
+ bool setUserName(const QString &newUserName);
+
bool isAnon() const;
void loadBlocks();
diff --git a/src/providers/twitch/TwitchAccountManager.cpp b/src/providers/twitch/TwitchAccountManager.cpp
index 3f02caff..1efeeff9 100644
--- a/src/providers/twitch/TwitchAccountManager.cpp
+++ b/src/providers/twitch/TwitchAccountManager.cpp
@@ -10,6 +10,7 @@
#include "common/Literals.hpp"
#include "common/network/NetworkResult.hpp"
#include "common/QLogging.hpp"
+#include "controllers/accounts/AccountController.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/TwitchAccount.hpp"
@@ -50,13 +51,13 @@ QString missingScopes(const QJsonArray &scopesArray)
return missingList;
}
-void checkMissingScopes(const QString &token)
+void checkMissingScopes(const std::shared_ptr &account)
{
NetworkRequest(u"https://id.twitch.tv/oauth2/validate"_s,
NetworkRequestType::Get)
- .header("Authorization", u"OAuth " % token)
+ .header("Authorization", u"OAuth " % account->getOAuthToken())
.timeout(20000)
- .onSuccess([](const auto &res) {
+ .onSuccess([account](const auto &res) {
auto *app = tryGetApp();
if (!app)
{
@@ -64,6 +65,15 @@ void checkMissingScopes(const QString &token)
}
const auto json = res.parseJson();
+
+ const auto login = json["login"_L1].toString();
+ if (!login.isEmpty() &&
+ login.compare(account->getUserName(), Qt::CaseInsensitive) != 0)
+ {
+ account->setUserName(login);
+ app->getAccounts()->twitch.currentUserNameChanged.invoke();
+ }
+
auto missing = missingScopes(json["scopes"_L1].toArray());
if (missing.isEmpty())
{
@@ -209,7 +219,7 @@ TwitchAccountManager::TwitchAccountManager()
currentUser->loadSeventvUserID();
if (!currentUser->isAnon())
{
- checkMissingScopes(currentUser->getOAuthToken());
+ checkMissingScopes(currentUser);
}
});
diff --git a/src/providers/twitch/TwitchAccountManager.hpp b/src/providers/twitch/TwitchAccountManager.hpp
index 3e4ca29c..88925fff 100644
--- a/src/providers/twitch/TwitchAccountManager.hpp
+++ b/src/providers/twitch/TwitchAccountManager.hpp
@@ -70,6 +70,7 @@ public:
boost::signals2::signal currentUserChanged;
pajlada::Signals::NoArgSignal userListUpdated;
+ pajlada::Signals::NoArgSignal currentUserNameChanged;
SignalVector> accounts;