Fix highlight mentions not updating when username changes (#6723)

Reported-by: James Upjohn <jupjohn@jammeh.co.nz>
Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
Reviewed-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
SonicSegFault
2026-01-11 23:22:38 +05:30
committed by GitHub
parent a8ac28425f
commit cffd86aa4f
6 changed files with 36 additions and 4 deletions
+1
View File
@@ -44,6 +44,7 @@
- Bugfix: Fixed <kbd>CMD</kbd> + <kbd>DELETE</kbd> 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)
@@ -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);
}
+10
View File
@@ -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<TwitchUser> &TwitchAccount::blocks() const
{
assertInGuiThread();
+4
View File
@@ -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();
+14 -4
View File
@@ -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<TwitchAccount> &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);
}
});
@@ -70,6 +70,7 @@ public:
boost::signals2::signal<void()> currentUserChanged;
pajlada::Signals::NoArgSignal userListUpdated;
pajlada::Signals::NoArgSignal currentUserNameChanged;
SignalVector<std::shared_ptr<TwitchAccount>> accounts;