Update to latest settings library version

This commit is contained in:
Rasmus Karlsson
2018-11-03 13:00:07 +01:00
parent 9ced50e94e
commit ac4a496a06
36 changed files with 373 additions and 374 deletions
+1 -1
View File
@@ -242,7 +242,7 @@ void Emojis::loadEmojiSet()
{
auto app = getApp();
getSettings()->emojiSet.connect([=](const auto &emojiSet, auto) {
getSettings()->emojiSet.connect([=](const auto &emojiSet) {
this->emojis.each([=](const auto &name,
std::shared_ptr<EmojiData> &emoji) {
QString emojiSetToUse = emojiSet;
+17 -18
View File
@@ -79,25 +79,25 @@ void TwitchAccountManager::reloadUsers()
continue;
}
std::string username = pajlada::Settings::Setting<std::string>::get(
auto username = pajlada::Settings::Setting<QString>::get(
"/accounts/" + uid + "/username");
std::string userID = pajlada::Settings::Setting<std::string>::get(
"/accounts/" + uid + "/userID");
std::string clientID = pajlada::Settings::Setting<std::string>::get(
auto userID = pajlada::Settings::Setting<QString>::get("/accounts/" +
uid + "/userID");
auto clientID = pajlada::Settings::Setting<QString>::get(
"/accounts/" + uid + "/clientID");
std::string oauthToken = pajlada::Settings::Setting<std::string>::get(
auto oauthToken = pajlada::Settings::Setting<QString>::get(
"/accounts/" + uid + "/oauthToken");
if (username.empty() || userID.empty() || clientID.empty() ||
oauthToken.empty())
if (username.isEmpty() || userID.isEmpty() || clientID.isEmpty() ||
oauthToken.isEmpty())
{
continue;
}
userData.username = qS(username).trimmed();
userData.userID = qS(userID).trimmed();
userData.clientID = qS(clientID).trimmed();
userData.oauthToken = qS(oauthToken).trimmed();
userData.username = username.trimmed();
userData.userID = userID.trimmed();
userData.clientID = clientID.trimmed();
userData.oauthToken = oauthToken.trimmed();
switch (this->addUser(userData))
{
@@ -138,8 +138,7 @@ void TwitchAccountManager::load()
{
this->reloadUsers();
this->currentUsername.connect([this](const auto &newValue, auto) {
QString newUsername(QString::fromStdString(newValue));
this->currentUsername.connect([this](const QString &newUsername) {
auto user = this->findUserByUsername(newUsername);
if (user)
{
@@ -175,14 +174,14 @@ bool TwitchAccountManager::removeUser(TwitchAccount *account)
{
const auto &accs = this->accounts.getVector();
std::string userID(account->getUserId().toStdString());
if (!userID.empty())
auto userID(account->getUserId());
if (!userID.isEmpty())
{
pajlada::Settings::SettingManager::removeSetting("/accounts/uid" +
userID);
pajlada::Settings::SettingManager::removeSetting(
fS("/accounts/uid{}", userID));
}
if (account->getUserName() == qS(this->currentUsername.getValue()))
if (account->getUserName() == this->currentUsername)
{
// The user that was removed is the current user, log into the anonymous
// user
@@ -1,11 +1,10 @@
#pragma once
#include "common/ChatterinoSetting.hpp"
#include "common/SignalVector.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "util/SharedPtrElementLess.hpp"
#include <pajlada/settings/setting.hpp>
#include <mutex>
#include <vector>
@@ -47,8 +46,7 @@ public:
bool isLoggedIn() const;
pajlada::Settings::Setting<std::string> currentUsername = {
"/accounts/current", ""};
QStringSetting currentUsername{"/accounts/current", ""};
pajlada::Signals::NoArgSignal currentUserChanged;
pajlada::Signals::NoArgSignal userListUpdated;
-2
View File
@@ -470,8 +470,6 @@ void TwitchChannel::refreshLiveStatus()
return;
}
log("[TwitchChannel:{}] Refreshing live status", this->getName());
QString url("https://api.twitch.tv/kraken/streams/" + roomID);
// auto request = makeGetStreamRequest(roomID, QThread::currentThread());
+34 -41
View File
@@ -4,7 +4,7 @@
#include <rapidjson/document.h>
#include <QString>
#include <pajlada/settings/serialize.hpp>
#include <pajlada/serialize.hpp>
#include <cassert>
@@ -32,49 +32,42 @@ struct TwitchUser {
} // namespace chatterino
namespace pajlada {
namespace Settings {
template <>
struct Deserialize<chatterino::TwitchUser> {
static chatterino::TwitchUser get(const rapidjson::Value &value,
bool *error = nullptr)
template <>
struct Deserialize<chatterino::TwitchUser> {
static chatterino::TwitchUser get(const rapidjson::Value &value,
bool *error = nullptr)
{
using namespace chatterino;
TwitchUser user;
if (!value.IsObject())
{
using namespace chatterino;
TwitchUser user;
if (!value.IsObject())
{
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION(
"Deserialized rapidjson::Value is wrong type");
return user;
}
if (!rj::getSafe(value, "_id", user.id))
{
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION("Missing ID key");
return user;
}
if (!rj::getSafe(value, "name", user.name))
{
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION("Missing name key");
return user;
}
if (!rj::getSafe(value, "display_name", user.displayName))
{
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION("Missing display name key");
return user;
}
PAJLADA_REPORT_ERROR(error)
return user;
}
};
} // namespace Settings
if (!rj::getSafe(value, "_id", user.id))
{
PAJLADA_REPORT_ERROR(error)
return user;
}
if (!rj::getSafe(value, "name", user.name))
{
PAJLADA_REPORT_ERROR(error)
return user;
}
if (!rj::getSafe(value, "display_name", user.displayName))
{
PAJLADA_REPORT_ERROR(error)
return user;
}
return user;
}
};
} // namespace pajlada