refactor: move seventv/bttv event apis to application (#5532)

This commit is contained in:
pajlada 2024-08-08 15:08:31 +02:00 committed by GitHub
parent 3257da1855
commit f0802af055
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 133 additions and 97 deletions

View file

@ -58,6 +58,7 @@
- Dev: The running Qt version is now shown in the about page if it differs from the compiled version. (#5501) - Dev: The running Qt version is now shown in the about page if it differs from the compiled version. (#5501)
- Dev: `FlagsEnum` is now `constexpr`. (#5510) - Dev: `FlagsEnum` is now `constexpr`. (#5510)
- Dev: Documented and added tests to RTL handling. (#5473) - Dev: Documented and added tests to RTL handling. (#5473)
- Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532)
- Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527) - Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
- Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529) - Dev: Prepared for Qt 6.8 by addressing some deprecations. (#5529)

View file

@ -2,6 +2,7 @@
#include "mocks/DisabledStreamerMode.hpp" #include "mocks/DisabledStreamerMode.hpp"
#include "mocks/EmptyApplication.hpp" #include "mocks/EmptyApplication.hpp"
#include "providers/bttv/BttvLiveUpdates.hpp"
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
#include <QString> #include <QString>
@ -30,6 +31,16 @@ public:
return &this->streamerMode; return &this->streamerMode;
} }
BttvLiveUpdates *getBttvLiveUpdates() override
{
return nullptr;
}
SeventvEventAPI *getSeventvEventAPI() override
{
return nullptr;
}
Settings settings; Settings settings;
DisabledStreamerMode streamerMode; DisabledStreamerMode streamerMode;
}; };

View file

@ -231,6 +231,13 @@ public:
return nullptr; return nullptr;
} }
BttvLiveUpdates *getBttvLiveUpdates() override
{
assert(false && "EmptyApplication::getBttvLiveUpdates was called "
"without being initialized");
return nullptr;
}
FfzEmotes *getFfzEmotes() override FfzEmotes *getFfzEmotes() override
{ {
assert(false && "EmptyApplication::getFfzEmotes was called without " assert(false && "EmptyApplication::getFfzEmotes was called without "
@ -245,6 +252,13 @@ public:
return nullptr; return nullptr;
} }
SeventvEventAPI *getSeventvEventAPI() override
{
assert(false && "EmptyApplication::getSeventvEventAPI was called "
"without being initialized");
return nullptr;
}
ILinkResolver *getLinkResolver() override ILinkResolver *getLinkResolver() override
{ {
assert(false && "EmptyApplication::getLinkResolver was called without " assert(false && "EmptyApplication::getLinkResolver was called without "

View file

@ -2,13 +2,11 @@
#include "mocks/Channel.hpp" #include "mocks/Channel.hpp"
#include "providers/bttv/BttvEmotes.hpp" #include "providers/bttv/BttvEmotes.hpp"
#include "providers/bttv/BttvLiveUpdates.hpp"
#include "providers/ffz/FfzEmotes.hpp" #include "providers/ffz/FfzEmotes.hpp"
#include "providers/seventv/eventapi/Client.hpp" #include "providers/seventv/eventapi/Client.hpp"
#include "providers/seventv/eventapi/Dispatch.hpp" #include "providers/seventv/eventapi/Dispatch.hpp"
#include "providers/seventv/eventapi/Message.hpp" #include "providers/seventv/eventapi/Message.hpp"
#include "providers/seventv/SeventvEmotes.hpp" #include "providers/seventv/SeventvEmotes.hpp"
#include "providers/seventv/SeventvEventAPI.hpp"
#include "providers/twitch/TwitchIrcServer.hpp" #include "providers/twitch/TwitchIrcServer.hpp"
namespace chatterino::mock { namespace chatterino::mock {
@ -46,16 +44,6 @@ public:
// //
} }
std::unique_ptr<BttvLiveUpdates> &getBTTVLiveUpdates() override
{
return this->bttvLiveUpdates;
}
std::unique_ptr<SeventvEventAPI> &getSeventvEventAPI() override
{
return this->seventvEventAPI;
}
const IndirectChannel &getWatchingChannel() const override const IndirectChannel &getWatchingChannel() const override
{ {
return this->watchingChannel; return this->watchingChannel;
@ -103,9 +91,6 @@ public:
ChannelPtr liveChannel; ChannelPtr liveChannel;
ChannelPtr automodChannel; ChannelPtr automodChannel;
QString lastUserThatWhisperedMe{"forsen"}; QString lastUserThatWhisperedMe{"forsen"};
std::unique_ptr<BttvLiveUpdates> bttvLiveUpdates;
std::unique_ptr<SeventvEventAPI> seventvEventAPI;
}; };
} // namespace chatterino::mock } // namespace chatterino::mock

View file

@ -72,6 +72,9 @@ namespace {
using namespace chatterino; using namespace chatterino;
const QString BTTV_LIVE_UPDATES_URL = "wss://sockets.betterttv.net/ws";
const QString SEVENTV_EVENTAPI_URL = "wss://events.7tv.io/v3";
ISoundController *makeSoundController(Settings &settings) ISoundController *makeSoundController(Settings &settings)
{ {
SoundBackend soundBackend = settings.soundBackend; SoundBackend soundBackend = settings.soundBackend;
@ -94,6 +97,31 @@ ISoundController *makeSoundController(Settings &settings)
} }
} }
BttvLiveUpdates *makeBttvLiveUpdates(Settings &settings)
{
bool enabled =
settings.enableBTTVLiveUpdates && settings.enableBTTVChannelEmotes;
if (enabled)
{
return new BttvLiveUpdates(BTTV_LIVE_UPDATES_URL);
}
return nullptr;
}
SeventvEventAPI *makeSeventvEventAPI(Settings &settings)
{
bool enabled = settings.enableSevenTVEventAPI;
if (enabled)
{
return new SeventvEventAPI(SEVENTV_EVENTAPI_URL);
}
return nullptr;
}
const QString TWITCH_PUBSUB_URL = "wss://pubsub-edge.twitch.tv"; const QString TWITCH_PUBSUB_URL = "wss://pubsub-edge.twitch.tv";
} // namespace } // namespace
@ -142,8 +170,10 @@ Application::Application(Settings &_settings, const Paths &paths,
, twitchBadges(new TwitchBadges) , twitchBadges(new TwitchBadges)
, chatterinoBadges(new ChatterinoBadges) , chatterinoBadges(new ChatterinoBadges)
, bttvEmotes(new BttvEmotes) , bttvEmotes(new BttvEmotes)
, bttvLiveUpdates(makeBttvLiveUpdates(_settings))
, ffzEmotes(new FfzEmotes) , ffzEmotes(new FfzEmotes)
, seventvEmotes(new SeventvEmotes) , seventvEmotes(new SeventvEmotes)
, seventvEventAPI(makeSeventvEventAPI(_settings))
, logging(new Logging(_settings)) , logging(new Logging(_settings))
, linkResolver(new LinkResolver) , linkResolver(new LinkResolver)
, streamerMode(new StreamerMode) , streamerMode(new StreamerMode)
@ -161,7 +191,10 @@ Application::Application(Settings &_settings, const Paths &paths,
}); });
} }
Application::~Application() = default; Application::~Application()
{
Application::instance = nullptr;
}
void Application::fakeDtor() void Application::fakeDtor()
{ {
@ -172,8 +205,10 @@ void Application::fakeDtor()
this->twitchBadges.reset(); this->twitchBadges.reset();
this->twitchLiveController.reset(); this->twitchLiveController.reset();
this->chatterinoBadges.reset(); this->chatterinoBadges.reset();
// this->bttvLiveUpdates.reset();
this->bttvEmotes.reset(); this->bttvEmotes.reset();
this->ffzEmotes.reset(); this->ffzEmotes.reset();
// this->seventvEventAPI.reset();
this->seventvEmotes.reset(); this->seventvEmotes.reset();
this->notifications.reset(); this->notifications.reset();
this->commands.reset(); this->commands.reset();
@ -194,6 +229,7 @@ void Application::fakeDtor()
this->accounts.reset(); this->accounts.reset();
this->emotes.reset(); this->emotes.reset();
this->themes.reset(); this->themes.reset();
this->streamerMode.reset();
} }
void Application::initialize(Settings &settings, const Paths &paths) void Application::initialize(Settings &settings, const Paths &paths)
@ -574,6 +610,14 @@ BttvEmotes *Application::getBttvEmotes()
return this->bttvEmotes.get(); return this->bttvEmotes.get();
} }
BttvLiveUpdates *Application::getBttvLiveUpdates()
{
assertInGuiThread();
// bttvLiveUpdates may be nullptr if it's not enabled
return this->bttvLiveUpdates.get();
}
FfzEmotes *Application::getFfzEmotes() FfzEmotes *Application::getFfzEmotes()
{ {
assertInGuiThread(); assertInGuiThread();
@ -590,6 +634,14 @@ SeventvEmotes *Application::getSeventvEmotes()
return this->seventvEmotes.get(); return this->seventvEmotes.get();
} }
SeventvEventAPI *Application::getSeventvEventAPI()
{
assertInGuiThread();
// seventvEventAPI may be nullptr if it's not enabled
return this->seventvEventAPI.get();
}
void Application::save() void Application::save()
{ {
this->commands->save(); this->commands->save();
@ -1066,9 +1118,7 @@ void Application::initPubSub()
void Application::initBttvLiveUpdates() void Application::initBttvLiveUpdates()
{ {
auto &bttvLiveUpdates = this->twitch->getBTTVLiveUpdates(); if (!this->bttvLiveUpdates)
if (!bttvLiveUpdates)
{ {
qCDebug(chatterinoBttv) qCDebug(chatterinoBttv)
<< "Skipping initialization of Live Updates as it's disabled"; << "Skipping initialization of Live Updates as it's disabled";
@ -1077,8 +1127,8 @@ void Application::initBttvLiveUpdates()
// We can safely ignore these signal connections since the twitch object will always // We can safely ignore these signal connections since the twitch object will always
// be destroyed before the Application // be destroyed before the Application
std::ignore = std::ignore = this->bttvLiveUpdates->signals_.emoteAdded.connect(
bttvLiveUpdates->signals_.emoteAdded.connect([&](const auto &data) { [&](const auto &data) {
auto chan = this->twitch->getChannelOrEmptyByID(data.channelID); auto chan = this->twitch->getChannelOrEmptyByID(data.channelID);
postToThread([chan, data] { postToThread([chan, data] {
@ -1088,8 +1138,8 @@ void Application::initBttvLiveUpdates()
} }
}); });
}); });
std::ignore = std::ignore = this->bttvLiveUpdates->signals_.emoteUpdated.connect(
bttvLiveUpdates->signals_.emoteUpdated.connect([&](const auto &data) { [&](const auto &data) {
auto chan = this->twitch->getChannelOrEmptyByID(data.channelID); auto chan = this->twitch->getChannelOrEmptyByID(data.channelID);
postToThread([chan, data] { postToThread([chan, data] {
@ -1099,8 +1149,8 @@ void Application::initBttvLiveUpdates()
} }
}); });
}); });
std::ignore = std::ignore = this->bttvLiveUpdates->signals_.emoteRemoved.connect(
bttvLiveUpdates->signals_.emoteRemoved.connect([&](const auto &data) { [&](const auto &data) {
auto chan = this->twitch->getChannelOrEmptyByID(data.channelID); auto chan = this->twitch->getChannelOrEmptyByID(data.channelID);
postToThread([chan, data] { postToThread([chan, data] {
@ -1110,14 +1160,12 @@ void Application::initBttvLiveUpdates()
} }
}); });
}); });
bttvLiveUpdates->start(); this->bttvLiveUpdates->start();
} }
void Application::initSeventvEventAPI() void Application::initSeventvEventAPI()
{ {
auto &seventvEventAPI = this->twitch->getSeventvEventAPI(); if (!this->seventvEventAPI)
if (!seventvEventAPI)
{ {
qCDebug(chatterinoSeventvEventAPI) qCDebug(chatterinoSeventvEventAPI)
<< "Skipping initialization as the EventAPI is disabled"; << "Skipping initialization as the EventAPI is disabled";
@ -1126,8 +1174,8 @@ void Application::initSeventvEventAPI()
// We can safely ignore these signal connections since the twitch object will always // We can safely ignore these signal connections since the twitch object will always
// be destroyed before the Application // be destroyed before the Application
std::ignore = std::ignore = this->seventvEventAPI->signals_.emoteAdded.connect(
seventvEventAPI->signals_.emoteAdded.connect([&](const auto &data) { [&](const auto &data) {
postToThread([this, data] { postToThread([this, data] {
this->twitch->forEachSeventvEmoteSet( this->twitch->forEachSeventvEmoteSet(
data.emoteSetID, [data](TwitchChannel &chan) { data.emoteSetID, [data](TwitchChannel &chan) {
@ -1135,8 +1183,8 @@ void Application::initSeventvEventAPI()
}); });
}); });
}); });
std::ignore = std::ignore = this->seventvEventAPI->signals_.emoteUpdated.connect(
seventvEventAPI->signals_.emoteUpdated.connect([&](const auto &data) { [&](const auto &data) {
postToThread([this, data] { postToThread([this, data] {
this->twitch->forEachSeventvEmoteSet( this->twitch->forEachSeventvEmoteSet(
data.emoteSetID, [data](TwitchChannel &chan) { data.emoteSetID, [data](TwitchChannel &chan) {
@ -1144,8 +1192,8 @@ void Application::initSeventvEventAPI()
}); });
}); });
}); });
std::ignore = std::ignore = this->seventvEventAPI->signals_.emoteRemoved.connect(
seventvEventAPI->signals_.emoteRemoved.connect([&](const auto &data) { [&](const auto &data) {
postToThread([this, data] { postToThread([this, data] {
this->twitch->forEachSeventvEmoteSet( this->twitch->forEachSeventvEmoteSet(
data.emoteSetID, [data](TwitchChannel &chan) { data.emoteSetID, [data](TwitchChannel &chan) {
@ -1153,15 +1201,15 @@ void Application::initSeventvEventAPI()
}); });
}); });
}); });
std::ignore = std::ignore = this->seventvEventAPI->signals_.userUpdated.connect(
seventvEventAPI->signals_.userUpdated.connect([&](const auto &data) { [&](const auto &data) {
this->twitch->forEachSeventvUser(data.userID, this->twitch->forEachSeventvUser(data.userID,
[data](TwitchChannel &chan) { [data](TwitchChannel &chan) {
chan.updateSeventvUser(data); chan.updateSeventvUser(data);
}); });
}); });
seventvEventAPI->start(); this->seventvEventAPI->start();
} }
IApplication *getApp() IApplication *getApp()

View file

@ -50,8 +50,10 @@ class ImageUploader;
class SeventvAPI; class SeventvAPI;
class CrashHandler; class CrashHandler;
class BttvEmotes; class BttvEmotes;
class BttvLiveUpdates;
class FfzEmotes; class FfzEmotes;
class SeventvEmotes; class SeventvEmotes;
class SeventvEventAPI;
class ILinkResolver; class ILinkResolver;
class IStreamerMode; class IStreamerMode;
class IAbstractIrcServer; class IAbstractIrcServer;
@ -97,8 +99,10 @@ public:
#endif #endif
virtual Updates &getUpdates() = 0; virtual Updates &getUpdates() = 0;
virtual BttvEmotes *getBttvEmotes() = 0; virtual BttvEmotes *getBttvEmotes() = 0;
virtual BttvLiveUpdates *getBttvLiveUpdates() = 0;
virtual FfzEmotes *getFfzEmotes() = 0; virtual FfzEmotes *getFfzEmotes() = 0;
virtual SeventvEmotes *getSeventvEmotes() = 0; virtual SeventvEmotes *getSeventvEmotes() = 0;
virtual SeventvEventAPI *getSeventvEventAPI() = 0;
virtual ILinkResolver *getLinkResolver() = 0; virtual ILinkResolver *getLinkResolver() = 0;
virtual IStreamerMode *getStreamerMode() = 0; virtual IStreamerMode *getStreamerMode() = 0;
}; };
@ -165,8 +169,10 @@ private:
std::unique_ptr<TwitchBadges> twitchBadges; std::unique_ptr<TwitchBadges> twitchBadges;
std::unique_ptr<ChatterinoBadges> chatterinoBadges; std::unique_ptr<ChatterinoBadges> chatterinoBadges;
std::unique_ptr<BttvEmotes> bttvEmotes; std::unique_ptr<BttvEmotes> bttvEmotes;
std::unique_ptr<BttvLiveUpdates> bttvLiveUpdates;
std::unique_ptr<FfzEmotes> ffzEmotes; std::unique_ptr<FfzEmotes> ffzEmotes;
std::unique_ptr<SeventvEmotes> seventvEmotes; std::unique_ptr<SeventvEmotes> seventvEmotes;
std::unique_ptr<SeventvEventAPI> seventvEventAPI;
const std::unique_ptr<Logging> logging; const std::unique_ptr<Logging> logging;
std::unique_ptr<ILinkResolver> linkResolver; std::unique_ptr<ILinkResolver> linkResolver;
std::unique_ptr<IStreamerMode> streamerMode; std::unique_ptr<IStreamerMode> streamerMode;
@ -218,8 +224,10 @@ public:
} }
BttvEmotes *getBttvEmotes() override; BttvEmotes *getBttvEmotes() override;
BttvLiveUpdates *getBttvLiveUpdates() override;
FfzEmotes *getFfzEmotes() override; FfzEmotes *getFfzEmotes() override;
SeventvEmotes *getSeventvEmotes() override; SeventvEmotes *getSeventvEmotes() override;
SeventvEventAPI *getSeventvEventAPI() override;
ILinkResolver *getLinkResolver() override; ILinkResolver *getLinkResolver() override;
IStreamerMode *getStreamerMode() override; IStreamerMode *getStreamerMode() override;

View file

@ -297,4 +297,5 @@ void runGui(QApplication &a, const Paths &paths, Settings &settings,
_exit(0); _exit(0);
} }
} // namespace chatterino } // namespace chatterino

View file

@ -146,15 +146,14 @@ TwitchChannel::~TwitchChannel()
getApp()->getTwitch()->dropSeventvChannel(this->seventvUserID_, getApp()->getTwitch()->dropSeventvChannel(this->seventvUserID_,
this->seventvEmoteSetID_); this->seventvEmoteSetID_);
if (getApp()->getTwitch()->getBTTVLiveUpdates()) if (getApp()->getBttvLiveUpdates())
{ {
getApp()->getTwitch()->getBTTVLiveUpdates()->partChannel( getApp()->getBttvLiveUpdates()->partChannel(this->roomId());
this->roomId());
} }
if (getApp()->getTwitch()->getSeventvEventAPI()) if (getApp()->getSeventvEventAPI())
{ {
getApp()->getTwitch()->getSeventvEventAPI()->unsubscribeTwitchChannel( getApp()->getSeventvEventAPI()->unsubscribeTwitchChannel(
this->roomId()); this->roomId());
} }
} }
@ -854,7 +853,7 @@ const QString &TwitchChannel::seventvEmoteSetID() const
void TwitchChannel::joinBttvChannel() const void TwitchChannel::joinBttvChannel() const
{ {
if (getApp()->getTwitch()->getBTTVLiveUpdates()) if (getApp()->getBttvLiveUpdates())
{ {
const auto currentAccount = const auto currentAccount =
getApp()->getAccounts()->twitch.getCurrent(); getApp()->getAccounts()->twitch.getCurrent();
@ -863,8 +862,7 @@ void TwitchChannel::joinBttvChannel() const
{ {
userName = currentAccount->getUserName(); userName = currentAccount->getUserName();
} }
getApp()->getTwitch()->getBTTVLiveUpdates()->joinChannel(this->roomId(), getApp()->getBttvLiveUpdates()->joinChannel(this->roomId(), userName);
userName);
} }
} }
@ -1012,9 +1010,9 @@ void TwitchChannel::updateSeventvData(const QString &newUserID,
this->seventvUserID_ = newUserID; this->seventvUserID_ = newUserID;
this->seventvEmoteSetID_ = newEmoteSetID; this->seventvEmoteSetID_ = newEmoteSetID;
runInGuiThread([this, oldUserID, oldEmoteSetID]() { runInGuiThread([this, oldUserID, oldEmoteSetID]() {
if (getApp()->getTwitch()->getSeventvEventAPI()) if (getApp()->getSeventvEventAPI())
{ {
getApp()->getTwitch()->getSeventvEventAPI()->subscribeUser( getApp()->getSeventvEventAPI()->subscribeUser(
this->seventvUserID_, this->seventvEmoteSetID_); this->seventvUserID_, this->seventvEmoteSetID_);
if (oldUserID || oldEmoteSetID) if (oldUserID || oldEmoteSetID)
@ -1811,10 +1809,9 @@ void TwitchChannel::updateSevenTVActivity()
void TwitchChannel::listenSevenTVCosmetics() const void TwitchChannel::listenSevenTVCosmetics() const
{ {
if (getApp()->getTwitch()->getSeventvEventAPI()) if (getApp()->getSeventvEventAPI())
{ {
getApp()->getTwitch()->getSeventvEventAPI()->subscribeTwitchChannel( getApp()->getSeventvEventAPI()->subscribeTwitchChannel(this->roomId());
this->roomId());
} }
} }

View file

@ -33,9 +33,6 @@ namespace {
using namespace chatterino; using namespace chatterino;
const QString BTTV_LIVE_UPDATES_URL = "wss://sockets.betterttv.net/ws";
const QString SEVENTV_EVENTAPI_URL = "wss://events.7tv.io/v3";
void sendHelixMessage(const std::shared_ptr<TwitchChannel> &channel, void sendHelixMessage(const std::shared_ptr<TwitchChannel> &channel,
const QString &message, const QString &replyParentId = {}) const QString &message, const QString &replyParentId = {})
{ {
@ -145,20 +142,6 @@ TwitchIrcServer::TwitchIrcServer()
{ {
this->initializeIrc(); this->initializeIrc();
if (getSettings()->enableBTTVLiveUpdates &&
getSettings()->enableBTTVChannelEmotes)
{
this->bttvLiveUpdates =
std::make_unique<BttvLiveUpdates>(BTTV_LIVE_UPDATES_URL);
}
if (getSettings()->enableSevenTVEventAPI &&
getSettings()->enableSevenTVChannelEmotes)
{
this->seventvEventAPI =
std::make_unique<SeventvEventAPI>(SEVENTV_EVENTAPI_URL);
}
// getSettings()->twitchSeperateWriteConnection.connect([this](auto, auto) { // getSettings()->twitchSeperateWriteConnection.connect([this](auto, auto) {
// this->connect(); }, // this->connect(); },
// this->signalHolder_, // this->signalHolder_,
@ -638,16 +621,6 @@ void TwitchIrcServer::onReplySendRequested(
sent = true; sent = true;
} }
std::unique_ptr<BttvLiveUpdates> &TwitchIrcServer::getBTTVLiveUpdates()
{
return this->bttvLiveUpdates;
}
std::unique_ptr<SeventvEventAPI> &TwitchIrcServer::getSeventvEventAPI()
{
return this->seventvEventAPI;
}
const IndirectChannel &TwitchIrcServer::getWatchingChannel() const const IndirectChannel &TwitchIrcServer::getWatchingChannel() const
{ {
return this->watchingChannel; return this->watchingChannel;
@ -759,7 +732,7 @@ void TwitchIrcServer::forEachSeventvUser(
void TwitchIrcServer::dropSeventvChannel(const QString &userID, void TwitchIrcServer::dropSeventvChannel(const QString &userID,
const QString &emoteSetID) const QString &emoteSetID)
{ {
if (!this->seventvEventAPI) if (!getApp()->getSeventvEventAPI())
{ {
return; return;
} }
@ -798,11 +771,11 @@ void TwitchIrcServer::dropSeventvChannel(const QString &userID,
if (!foundUser) if (!foundUser)
{ {
this->seventvEventAPI->unsubscribeUser(userID); getApp()->getSeventvEventAPI()->unsubscribeUser(userID);
} }
if (!foundSet) if (!foundSet)
{ {
this->seventvEventAPI->unsubscribeEmoteSet(emoteSetID); getApp()->getSeventvEventAPI()->unsubscribeEmoteSet(emoteSetID);
} }
} }

View file

@ -15,8 +15,6 @@ namespace chatterino {
class Settings; class Settings;
class Paths; class Paths;
class TwitchChannel; class TwitchChannel;
class BttvLiveUpdates;
class SeventvEventAPI;
class BttvEmotes; class BttvEmotes;
class FfzEmotes; class FfzEmotes;
class SeventvEmotes; class SeventvEmotes;
@ -35,9 +33,6 @@ public:
virtual void dropSeventvChannel(const QString &userID, virtual void dropSeventvChannel(const QString &userID,
const QString &emoteSetID) = 0; const QString &emoteSetID) = 0;
virtual std::unique_ptr<BttvLiveUpdates> &getBTTVLiveUpdates() = 0;
virtual std::unique_ptr<SeventvEventAPI> &getSeventvEventAPI() = 0;
virtual const IndirectChannel &getWatchingChannel() const = 0; virtual const IndirectChannel &getWatchingChannel() const = 0;
virtual void setWatchingChannel(ChannelPtr newWatchingChannel) = 0; virtual void setWatchingChannel(ChannelPtr newWatchingChannel) = 0;
virtual ChannelPtr getWhispersChannel() const = 0; virtual ChannelPtr getWhispersChannel() const = 0;
@ -102,13 +97,7 @@ private:
const ChannelPtr automodChannel; const ChannelPtr automodChannel;
IndirectChannel watchingChannel; IndirectChannel watchingChannel;
std::unique_ptr<BttvLiveUpdates> bttvLiveUpdates;
std::unique_ptr<SeventvEventAPI> seventvEventAPI;
public: public:
std::unique_ptr<BttvLiveUpdates> &getBTTVLiveUpdates() override;
std::unique_ptr<SeventvEventAPI> &getSeventvEventAPI() override;
const IndirectChannel &getWatchingChannel() const override; const IndirectChannel &getWatchingChannel() const override;
void setWatchingChannel(ChannelPtr newWatchingChannel) override; void setWatchingChannel(ChannelPtr newWatchingChannel) override;
ChannelPtr getWhispersChannel() const override; ChannelPtr getWhispersChannel() const override;

View file

@ -152,6 +152,11 @@ class StreamerModePrivate
{ {
public: public:
StreamerModePrivate(StreamerMode *parent_); StreamerModePrivate(StreamerMode *parent_);
~StreamerModePrivate();
StreamerModePrivate(const StreamerModePrivate &) = delete;
StreamerModePrivate(StreamerModePrivate &&) = delete;
StreamerModePrivate &operator=(const StreamerModePrivate &) = delete;
StreamerModePrivate &operator=(StreamerModePrivate &&) = delete;
[[nodiscard]] bool isEnabled() const; [[nodiscard]] bool isEnabled() const;
@ -219,6 +224,12 @@ StreamerModePrivate::StreamerModePrivate(StreamerMode *parent)
this->thread_.start(); this->thread_.start();
} }
StreamerModePrivate::~StreamerModePrivate()
{
this->thread_.quit();
this->thread_.wait(50);
}
bool StreamerModePrivate::isEnabled() const bool StreamerModePrivate::isEnabled() const
{ {
this->timeouts_.store(SKIPPED_TIMEOUTS, std::memory_order::relaxed); this->timeouts_.store(SKIPPED_TIMEOUTS, std::memory_order::relaxed);

View file

@ -3,7 +3,7 @@
#include "controllers/commands/CommandContext.hpp" #include "controllers/commands/CommandContext.hpp"
#include "controllers/commands/CommandController.hpp" #include "controllers/commands/CommandController.hpp"
#include "controllers/commands/common/ChannelAction.hpp" #include "controllers/commands/common/ChannelAction.hpp"
#include "mocks/EmptyApplication.hpp" #include "mocks/BaseApplication.hpp"
#include "mocks/Helix.hpp" #include "mocks/Helix.hpp"
#include "mocks/Logging.hpp" #include "mocks/Logging.hpp"
#include "mocks/TwitchIrcServer.hpp" #include "mocks/TwitchIrcServer.hpp"
@ -22,12 +22,11 @@ using ::testing::StrictMock;
namespace { namespace {
class MockApplication : mock::EmptyApplication class MockApplication : public mock::BaseApplication
{ {
public: public:
MockApplication() MockApplication()
: settings(this->settingsDir.filePath("settings.json")) : commands(this->paths_)
, commands(this->paths_)
{ {
} }
@ -56,7 +55,6 @@ public:
return &this->chatLogger; return &this->chatLogger;
} }
Settings settings;
AccountController accounts; AccountController accounts;
CommandController commands; CommandController commands;
mock::MockTwitchIrcServer twitch; mock::MockTwitchIrcServer twitch;