mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fix currentUser thing
This commit is contained in:
parent
c8c65f8f09
commit
903cf30ddf
3 changed files with 16 additions and 6 deletions
|
@ -20,7 +20,8 @@ inline QString getEnvString(const char *target)
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AccountManager::AccountManager()
|
AccountManager::AccountManager()
|
||||||
: twitchAnonymousUser("justinfan64537", "", "")
|
: currentUser("/accounts/current", "")
|
||||||
|
, twitchAnonymousUser("justinfan64537", "", "")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +29,8 @@ void AccountManager::load()
|
||||||
{
|
{
|
||||||
auto keys = pajlada::Settings::SettingManager::getObjectKeys("/accounts");
|
auto keys = pajlada::Settings::SettingManager::getObjectKeys("/accounts");
|
||||||
|
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
for (const auto &uid : keys) {
|
for (const auto &uid : keys) {
|
||||||
if (uid == "current") {
|
if (uid == "current") {
|
||||||
continue;
|
continue;
|
||||||
|
@ -46,6 +49,11 @@ void AccountManager::load()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (first) {
|
||||||
|
this->setCurrentTwitchUser(qS(username));
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
|
||||||
twitch::TwitchUser user(qS(username), qS(oauthToken), qS(clientID));
|
twitch::TwitchUser user(qS(username), qS(oauthToken), qS(clientID));
|
||||||
|
|
||||||
this->addTwitchUser(user);
|
this->addTwitchUser(user);
|
||||||
|
@ -67,9 +75,7 @@ twitch::TwitchUser &AccountManager::getTwitchUser()
|
||||||
return this->getTwitchAnon();
|
return this->getTwitchAnon();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string currentUser = pajlada::Settings::Setting<std::string>::get("/accounts/current");
|
QString currentUsername = QString::fromStdString(this->currentUser);
|
||||||
|
|
||||||
QString currentUsername = QString::fromStdString(currentUser);
|
|
||||||
|
|
||||||
for (auto &user : this->twitchUsers) {
|
for (auto &user : this->twitchUsers) {
|
||||||
if (user.getUserName() == currentUsername) {
|
if (user.getUserName() == currentUsername) {
|
||||||
|
@ -82,7 +88,7 @@ twitch::TwitchUser &AccountManager::getTwitchUser()
|
||||||
|
|
||||||
void AccountManager::setCurrentTwitchUser(const QString &username)
|
void AccountManager::setCurrentTwitchUser(const QString &username)
|
||||||
{
|
{
|
||||||
pajlada::Settings::Setting<std::string>::set("/accounts/current", username.toStdString());
|
this->currentUser.setValue(username.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<twitch::TwitchUser> AccountManager::getTwitchUsers()
|
std::vector<twitch::TwitchUser> AccountManager::getTwitchUsers()
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "twitch/twitchuser.hpp"
|
#include "twitch/twitchuser.hpp"
|
||||||
|
|
||||||
|
#include <pajlada/settings/setting.hpp>
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -37,6 +39,8 @@ public:
|
||||||
private:
|
private:
|
||||||
AccountManager();
|
AccountManager();
|
||||||
|
|
||||||
|
pajlada::Settings::Setting<std::string> currentUser;
|
||||||
|
|
||||||
twitch::TwitchUser twitchAnonymousUser;
|
twitch::TwitchUser twitchAnonymousUser;
|
||||||
std::vector<twitch::TwitchUser> twitchUsers;
|
std::vector<twitch::TwitchUser> twitchUsers;
|
||||||
std::mutex twitchUsersMutex;
|
std::mutex twitchUsersMutex;
|
||||||
|
|
|
@ -362,7 +362,7 @@ void TwitchMessageBuilder::parseHighlights()
|
||||||
{
|
{
|
||||||
static auto player = new QMediaPlayer;
|
static auto player = new QMediaPlayer;
|
||||||
SettingsManager &settings = SettingsManager::getInstance();
|
SettingsManager &settings = SettingsManager::getInstance();
|
||||||
static pajlada::Settings::Setting<std::string> currentUser("/accounts/currentUser");
|
static pajlada::Settings::Setting<std::string> currentUser("/accounts/current");
|
||||||
|
|
||||||
QString currentUsername = QString::fromStdString(currentUser.getValue());
|
QString currentUsername = QString::fromStdString(currentUser.getValue());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue