mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
move some logic abou updated state to twitchuser
This commit is contained in:
parent
0ca4a098e1
commit
03962db367
4 changed files with 25 additions and 11 deletions
|
@ -170,13 +170,12 @@ TwitchAccountManager::AddUserResponse TwitchAccountManager::addUser(
|
||||||
auto previousUser = this->findUserByUsername(userData.username);
|
auto previousUser = this->findUserByUsername(userData.username);
|
||||||
if (previousUser) {
|
if (previousUser) {
|
||||||
bool userUpdated = false;
|
bool userUpdated = false;
|
||||||
if (previousUser->getOAuthClient().compare(userData.clientID) != 0) {
|
|
||||||
previousUser->setOAuthClient(userData.clientID);
|
if (previousUser->setOAuthClient(userData.clientID)) {
|
||||||
userUpdated = true;
|
userUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previousUser->getOAuthToken().compare(userData.oauthToken) != 0) {
|
if (previousUser->setOAuthToken(userData.oauthToken)) {
|
||||||
previousUser->setOAuthToken(userData.oauthToken);
|
|
||||||
userUpdated = true;
|
userUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,14 +34,26 @@ void TwitchUser::setUserId(const QString &id)
|
||||||
this->_userId = id;
|
this->_userId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchUser::setOAuthClient(const QString &newClientID)
|
bool TwitchUser::setOAuthClient(const QString &newClientID)
|
||||||
{
|
{
|
||||||
this->_oauthClient = newClientID;
|
if (this->_oauthClient.compare(newClientID) == 0) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchUser::setOAuthToken(const QString &newOAuthToken)
|
this->_oauthClient = newClientID;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TwitchUser::setOAuthToken(const QString &newOAuthToken)
|
||||||
{
|
{
|
||||||
|
if (this->_oauthToken.compare(newOAuthToken) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
this->_oauthToken = newOAuthToken;
|
this->_oauthToken = newOAuthToken;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitchUser::isAnon() const
|
bool TwitchUser::isAnon() const
|
||||||
|
|
|
@ -17,8 +17,13 @@ public:
|
||||||
const QString &getUserId() const;
|
const QString &getUserId() const;
|
||||||
void setUserId(const QString &id);
|
void setUserId(const QString &id);
|
||||||
|
|
||||||
void setOAuthClient(const QString &newClientID);
|
// Attempts to update the users OAuth Client ID
|
||||||
void setOAuthToken(const QString &newClientID);
|
// Returns true if the value has changed, otherwise false
|
||||||
|
bool setOAuthClient(const QString &newClientID);
|
||||||
|
|
||||||
|
// Attempts to update the users OAuth Token
|
||||||
|
// Returns true if the value has changed, otherwise false
|
||||||
|
bool setOAuthToken(const QString &newOAuthToken);
|
||||||
|
|
||||||
bool isAnon() const;
|
bool isAnon() const;
|
||||||
|
|
||||||
|
@ -26,7 +31,7 @@ private:
|
||||||
QString _oauthClient;
|
QString _oauthClient;
|
||||||
QString _oauthToken;
|
QString _oauthToken;
|
||||||
QString _userId;
|
QString _userId;
|
||||||
bool _isAnon;
|
const bool _isAnon;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace twitch
|
} // namespace twitch
|
||||||
|
|
|
@ -31,8 +31,6 @@ protected:
|
||||||
virtual void changeEvent(QEvent *) override;
|
virtual void changeEvent(QEvent *) override;
|
||||||
virtual void leaveEvent(QEvent *) override;
|
virtual void leaveEvent(QEvent *) override;
|
||||||
|
|
||||||
// XXX: Should this be pure virtual?
|
|
||||||
// fourtf: hell no
|
|
||||||
virtual void dpiMultiplierChanged(float /*oldDpi*/, float /*newDpi*/)
|
virtual void dpiMultiplierChanged(float /*oldDpi*/, float /*newDpi*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue