refactor: Make ChatterinoBadges less of a singleton (#5103)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "ChatterinoBadges.hpp"
|
||||
#include "providers/chatterino/ChatterinoBadges.hpp"
|
||||
|
||||
#include "common/network/NetworkRequest.hpp"
|
||||
#include "common/network/NetworkResult.hpp"
|
||||
@@ -7,17 +7,13 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QThread>
|
||||
#include <QUrl>
|
||||
|
||||
namespace chatterino {
|
||||
void ChatterinoBadges::initialize(Settings &settings, const Paths &paths)
|
||||
{
|
||||
this->loadChatterinoBadges();
|
||||
}
|
||||
|
||||
ChatterinoBadges::ChatterinoBadges()
|
||||
{
|
||||
this->loadChatterinoBadges();
|
||||
}
|
||||
|
||||
std::optional<EmotePtr> ChatterinoBadges::getBadge(const UserId &id)
|
||||
@@ -44,15 +40,19 @@ void ChatterinoBadges::loadChatterinoBadges()
|
||||
std::unique_lock lock(this->mutex_);
|
||||
|
||||
int index = 0;
|
||||
for (const auto &jsonBadge_ : jsonRoot.value("badges").toArray())
|
||||
for (const auto &jsonBadgeValue :
|
||||
jsonRoot.value("badges").toArray())
|
||||
{
|
||||
auto jsonBadge = jsonBadge_.toObject();
|
||||
auto jsonBadge = jsonBadgeValue.toObject();
|
||||
auto emote = Emote{
|
||||
EmoteName{},
|
||||
ImageSet{Url{jsonBadge.value("image1").toString()},
|
||||
Url{jsonBadge.value("image2").toString()},
|
||||
Url{jsonBadge.value("image3").toString()}},
|
||||
Tooltip{jsonBadge.value("tooltip").toString()}, Url{}};
|
||||
.name = EmoteName{},
|
||||
.images =
|
||||
ImageSet{Url{jsonBadge.value("image1").toString()},
|
||||
Url{jsonBadge.value("image2").toString()},
|
||||
Url{jsonBadge.value("image3").toString()}},
|
||||
.tooltip = Tooltip{jsonBadge.value("tooltip").toString()},
|
||||
.homePage = Url{},
|
||||
};
|
||||
|
||||
emotes.push_back(
|
||||
std::make_shared<const Emote>(std::move(emote)));
|
||||
|
||||
Reference in New Issue
Block a user