mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
refactor: Make ChatterinoBadges a non-singleton
This commit is contained in:
parent
5bf1a5a7dd
commit
54da03a5bd
4 changed files with 15 additions and 16 deletions
|
@ -127,7 +127,6 @@ Application::Application(Settings &_settings, const Paths &paths,
|
|||
, notifications(&this->emplace<NotificationController>())
|
||||
, highlights(&this->emplace<HighlightController>())
|
||||
, twitch(&this->emplace<TwitchIrcServer>())
|
||||
, chatterinoBadges(&this->emplace<ChatterinoBadges>())
|
||||
, ffzBadges(&this->emplace<FfzBadges>())
|
||||
, seventvBadges(&this->emplace<SeventvBadges>())
|
||||
, userData(&this->emplace(new UserDataController(paths)))
|
||||
|
@ -135,6 +134,7 @@ Application::Application(Settings &_settings, const Paths &paths,
|
|||
, twitchLiveController(&this->emplace<TwitchLiveController>())
|
||||
, twitchPubSub(new PubSub(TWITCH_PUBSUB_URL))
|
||||
, twitchBadges(new TwitchBadges)
|
||||
, chatterinoBadges(new ChatterinoBadges)
|
||||
, logging(new Logging(_settings))
|
||||
#ifdef CHATTERINO_HAVE_PLUGINS
|
||||
, plugins(&this->emplace(new PluginController(paths)))
|
||||
|
@ -156,6 +156,7 @@ void Application::fakeDtor()
|
|||
{
|
||||
this->twitchPubSub.reset();
|
||||
this->twitchBadges.reset();
|
||||
this->chatterinoBadges.reset();
|
||||
}
|
||||
|
||||
void Application::initialize(Settings &settings, const Paths &paths)
|
||||
|
@ -339,6 +340,14 @@ TwitchBadges *Application::getTwitchBadges()
|
|||
return this->twitchBadges.get();
|
||||
}
|
||||
|
||||
ChatterinoBadges *Application::getChatterinoBadges()
|
||||
{
|
||||
assertInGuiThread();
|
||||
assert(this->chatterinoBadges);
|
||||
|
||||
return this->chatterinoBadges.get();
|
||||
}
|
||||
|
||||
ITwitchIrcServer *Application::getTwitch()
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
|
|
@ -136,7 +136,6 @@ public:
|
|||
NotificationController *const notifications{};
|
||||
HighlightController *const highlights{};
|
||||
TwitchIrcServer *const twitch{};
|
||||
ChatterinoBadges *const chatterinoBadges{};
|
||||
FfzBadges *const ffzBadges{};
|
||||
SeventvBadges *const seventvBadges{};
|
||||
UserDataController *const userData{};
|
||||
|
@ -146,6 +145,7 @@ private:
|
|||
TwitchLiveController *const twitchLiveController{};
|
||||
std::unique_ptr<PubSub> twitchPubSub;
|
||||
std::unique_ptr<TwitchBadges> twitchBadges;
|
||||
std::unique_ptr<ChatterinoBadges> chatterinoBadges;
|
||||
const std::unique_ptr<Logging> logging;
|
||||
|
||||
public:
|
||||
|
@ -225,12 +225,6 @@ public:
|
|||
ITwitchIrcServer *getTwitch() override;
|
||||
PubSub *getTwitchPubSub() override;
|
||||
Logging *getChatLogger() override;
|
||||
ChatterinoBadges *getChatterinoBadges() override
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
return this->chatterinoBadges;
|
||||
}
|
||||
FfzBadges *getFfzBadges() override
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
@ -247,6 +241,7 @@ public:
|
|||
ISoundController *getSound() override;
|
||||
ITwitchLiveController *getTwitchLiveController() override;
|
||||
TwitchBadges *getTwitchBadges() override;
|
||||
ChatterinoBadges *getChatterinoBadges() override;
|
||||
ImageUploader *getImageUploader() override
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "ChatterinoBadges.hpp"
|
||||
#include "providers/chatterino/ChatterinoBadges.hpp"
|
||||
|
||||
#include "common/network/NetworkRequest.hpp"
|
||||
#include "common/network/NetworkResult.hpp"
|
||||
|
@ -11,13 +11,10 @@
|
|||
#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)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/Aliases.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
@ -15,10 +14,9 @@ namespace chatterino {
|
|||
struct Emote;
|
||||
using EmotePtr = std::shared_ptr<const Emote>;
|
||||
|
||||
class ChatterinoBadges : public Singleton
|
||||
class ChatterinoBadges
|
||||
{
|
||||
public:
|
||||
void initialize(Settings &settings, const Paths &paths) override;
|
||||
ChatterinoBadges();
|
||||
|
||||
std::optional<EmotePtr> getBadge(const UserId &id);
|
||||
|
|
Loading…
Reference in a new issue