refactor: turn StreamerMode into a singleton(-like thing) (#5216)

This commit is contained in:
nerix
2024-03-01 21:12:02 +01:00
committed by GitHub
parent ea19c5c989
commit c1fa51242f
28 changed files with 386 additions and 210 deletions
+11 -5
View File
@@ -51,6 +51,7 @@
#include "singletons/Logging.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include "singletons/StreamerMode.hpp"
#include "singletons/Theme.hpp"
#include "singletons/Toasts.hpp"
#include "singletons/Updates.hpp"
@@ -144,6 +145,7 @@ Application::Application(Settings &_settings, const Paths &paths,
, seventvEmotes(new SeventvEmotes)
, logging(new Logging(_settings))
, linkResolver(new LinkResolver)
, streamerMode(new StreamerMode)
#ifdef CHATTERINO_HAVE_PLUGINS
, plugins(&this->emplace(new PluginController(paths)))
#endif
@@ -503,6 +505,11 @@ ILinkResolver *Application::getLinkResolver()
return this->linkResolver.get();
}
IStreamerMode *Application::getStreamerMode()
{
return this->streamerMode.get();
}
BttvEmotes *Application::getBttvEmotes()
{
assertInGuiThread();
@@ -707,7 +714,7 @@ void Application::initPubSub()
}
if (getSettings()->streamerModeHideModActions &&
isInStreamerMode())
this->getStreamerMode()->isEnabled())
{
return;
}
@@ -756,7 +763,7 @@ void Application::initPubSub()
}
if (getSettings()->streamerModeHideModActions &&
isInStreamerMode())
this->getStreamerMode()->isEnabled())
{
return;
}
@@ -892,9 +899,8 @@ void Application::initPubSub()
std::ignore = this->twitchPubSub->moderation.automodUserMessage.connect(
[&](const auto &action) {
// This condition has been set up to execute isInStreamerMode() as the last thing
// as it could end up being expensive.
if (getSettings()->streamerModeHideModActions && isInStreamerMode())
if (getSettings()->streamerModeHideModActions &&
this->getStreamerMode()->isEnabled())
{
return;
}