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:
@@ -44,6 +44,7 @@
|
|||||||
- Bugfix: Fixed <kbd>CMD</kbd> + <kbd>DELETE</kbd> behavior in the user notes editing dialog for macOS. (#6676)
|
- 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: 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: 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)
|
- Bugfix: Fixed Return and Enter being treated as different keys on Mac OS. (#6726)
|
||||||
- Dev: Update release documentation. (#6498)
|
- 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)
|
- 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->rebuildChecks(settings);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this->signalHolder_.managedConnect(
|
||||||
|
accounts->twitch.currentUserNameChanged, [this, &settings] {
|
||||||
|
qCDebug(chatterinoHighlights)
|
||||||
|
<< "Rebuild checks because user name changed";
|
||||||
|
this->rebuildChecks(settings);
|
||||||
|
});
|
||||||
this->rebuildChecks(settings);
|
this->rebuildChecks(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,6 +194,16 @@ void TwitchAccount::blockUserLocally(const QString &userID,
|
|||||||
this->ignoresUserLogins_.insert(blockedUser.name);
|
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
|
const std::unordered_set<TwitchUser> &TwitchAccount::blocks() const
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ public:
|
|||||||
// Returns true if the value has changed, otherwise false
|
// Returns true if the value has changed, otherwise false
|
||||||
bool setOAuthToken(const QString &newOAuthToken);
|
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;
|
bool isAnon() const;
|
||||||
|
|
||||||
void loadBlocks();
|
void loadBlocks();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "common/Literals.hpp"
|
#include "common/Literals.hpp"
|
||||||
#include "common/network/NetworkResult.hpp"
|
#include "common/network/NetworkResult.hpp"
|
||||||
#include "common/QLogging.hpp"
|
#include "common/QLogging.hpp"
|
||||||
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "providers/twitch/api/Helix.hpp"
|
#include "providers/twitch/api/Helix.hpp"
|
||||||
#include "providers/twitch/TwitchAccount.hpp"
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
@@ -50,13 +51,13 @@ QString missingScopes(const QJsonArray &scopesArray)
|
|||||||
return missingList;
|
return missingList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkMissingScopes(const QString &token)
|
void checkMissingScopes(const std::shared_ptr<TwitchAccount> &account)
|
||||||
{
|
{
|
||||||
NetworkRequest(u"https://id.twitch.tv/oauth2/validate"_s,
|
NetworkRequest(u"https://id.twitch.tv/oauth2/validate"_s,
|
||||||
NetworkRequestType::Get)
|
NetworkRequestType::Get)
|
||||||
.header("Authorization", u"OAuth " % token)
|
.header("Authorization", u"OAuth " % account->getOAuthToken())
|
||||||
.timeout(20000)
|
.timeout(20000)
|
||||||
.onSuccess([](const auto &res) {
|
.onSuccess([account](const auto &res) {
|
||||||
auto *app = tryGetApp();
|
auto *app = tryGetApp();
|
||||||
if (!app)
|
if (!app)
|
||||||
{
|
{
|
||||||
@@ -64,6 +65,15 @@ void checkMissingScopes(const QString &token)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto json = res.parseJson();
|
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());
|
auto missing = missingScopes(json["scopes"_L1].toArray());
|
||||||
if (missing.isEmpty())
|
if (missing.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -209,7 +219,7 @@ TwitchAccountManager::TwitchAccountManager()
|
|||||||
currentUser->loadSeventvUserID();
|
currentUser->loadSeventvUserID();
|
||||||
if (!currentUser->isAnon())
|
if (!currentUser->isAnon())
|
||||||
{
|
{
|
||||||
checkMissingScopes(currentUser->getOAuthToken());
|
checkMissingScopes(currentUser);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public:
|
|||||||
|
|
||||||
boost::signals2::signal<void()> currentUserChanged;
|
boost::signals2::signal<void()> currentUserChanged;
|
||||||
pajlada::Signals::NoArgSignal userListUpdated;
|
pajlada::Signals::NoArgSignal userListUpdated;
|
||||||
|
pajlada::Signals::NoArgSignal currentUserNameChanged;
|
||||||
|
|
||||||
SignalVector<std::shared_ptr<TwitchAccount>> accounts;
|
SignalVector<std::shared_ptr<TwitchAccount>> accounts;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user