2017-12-31 00:50:07 +01:00
|
|
|
|
#include "singletons/accountmanager.hpp"
|
|
|
|
|
|
|
|
|
|
namespace chatterino {
|
2017-12-31 22:58:35 +01:00
|
|
|
|
namespace singletons {
|
2017-12-31 00:50:07 +01:00
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
inline QString getEnvString(const char *target)
|
|
|
|
|
{
|
|
|
|
|
char *val = std::getenv(target);
|
|
|
|
|
if (val == nullptr) {
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QString(val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
AccountManager::AccountManager()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AccountManager &AccountManager::getInstance()
|
|
|
|
|
{
|
|
|
|
|
static AccountManager instance;
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AccountManager::load()
|
|
|
|
|
{
|
|
|
|
|
this->Twitch.reloadUsers();
|
|
|
|
|
|
|
|
|
|
auto currentUser = this->Twitch.findUserByUsername(
|
|
|
|
|
QString::fromStdString(this->Twitch.currentUsername.getValue()));
|
|
|
|
|
|
|
|
|
|
if (currentUser) {
|
|
|
|
|
this->Twitch.currentUser = currentUser;
|
|
|
|
|
} else {
|
|
|
|
|
this->Twitch.currentUser = this->Twitch.anonymousUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->Twitch.userChanged.invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace chatterino
|
2017-12-31 22:58:35 +01:00
|
|
|
|
}
|