refactor: Move Emotes to Application (#5120)

This commit is contained in:
pajlada
2024-01-21 14:20:21 +01:00
committed by GitHub
parent 65d3e73c5d
commit 5628605de4
14 changed files with 152 additions and 72 deletions
+1
View File
@@ -18,6 +18,7 @@
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/bttv/BttvLiveUpdates.hpp"
#include "providers/bttv/liveupdates/BttvLiveUpdateMessages.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/recentmessages/Api.hpp"
#include "providers/seventv/eventapi/Dispatch.hpp"
#include "providers/seventv/SeventvAPI.hpp"
+6 -16
View File
@@ -7,8 +7,11 @@
#include "controllers/accounts/AccountController.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/bttv/BttvLiveUpdates.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/seventv/eventapi/Subscription.hpp"
#include "providers/seventv/SeventvEmotes.hpp"
#include "providers/seventv/SeventvEventAPI.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/ChannelPointReward.hpp"
@@ -517,19 +520,6 @@ void TwitchIrcServer::onReplySendRequested(TwitchChannel *channel,
sent = true;
}
const BttvEmotes &TwitchIrcServer::getBttvEmotes() const
{
return this->bttv;
}
const FfzEmotes &TwitchIrcServer::getFfzEmotes() const
{
return this->ffz;
}
const SeventvEmotes &TwitchIrcServer::getSeventvEmotes() const
{
return this->seventv_;
}
const IndirectChannel &TwitchIrcServer::getWatchingChannel() const
{
return this->watchingChannel;
@@ -537,7 +527,7 @@ const IndirectChannel &TwitchIrcServer::getWatchingChannel() const
void TwitchIrcServer::reloadBTTVGlobalEmotes()
{
this->bttv.loadEmotes();
getIApp()->getBttvEmotes()->loadEmotes();
}
void TwitchIrcServer::reloadAllBTTVChannelEmotes()
@@ -552,7 +542,7 @@ void TwitchIrcServer::reloadAllBTTVChannelEmotes()
void TwitchIrcServer::reloadFFZGlobalEmotes()
{
this->ffz.loadEmotes();
getIApp()->getFfzEmotes()->loadEmotes();
}
void TwitchIrcServer::reloadAllFFZChannelEmotes()
@@ -567,7 +557,7 @@ void TwitchIrcServer::reloadAllFFZChannelEmotes()
void TwitchIrcServer::reloadSevenTVGlobalEmotes()
{
this->seventv_.loadGlobalEmotes();
getIApp()->getSeventvEmotes()->loadGlobalEmotes();
}
void TwitchIrcServer::reloadAllSevenTVChannelEmotes()
+3 -13
View File
@@ -3,10 +3,7 @@
#include "common/Atomic.hpp"
#include "common/Channel.hpp"
#include "common/Singleton.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/irc/AbstractIrcServer.hpp"
#include "providers/seventv/SeventvEmotes.hpp"
#include <pajlada/signals/signalholder.hpp>
@@ -21,15 +18,15 @@ class Paths;
class TwitchChannel;
class BttvLiveUpdates;
class SeventvEventAPI;
class BttvEmotes;
class FfzEmotes;
class SeventvEmotes;
class ITwitchIrcServer
{
public:
virtual ~ITwitchIrcServer() = default;
virtual const BttvEmotes &getBttvEmotes() const = 0;
virtual const FfzEmotes &getFfzEmotes() const = 0;
virtual const SeventvEmotes &getSeventvEmotes() const = 0;
virtual const IndirectChannel &getWatchingChannel() const = 0;
// Update this interface with TwitchIrcServer methods as needed
@@ -82,9 +79,6 @@ public:
std::unique_ptr<BttvLiveUpdates> bttvLiveUpdates;
std::unique_ptr<SeventvEventAPI> seventvEventAPI;
const BttvEmotes &getBttvEmotes() const override;
const FfzEmotes &getFfzEmotes() const override;
const SeventvEmotes &getSeventvEmotes() const override;
const IndirectChannel &getWatchingChannel() const override;
protected:
@@ -116,10 +110,6 @@ private:
std::chrono::steady_clock::time_point lastErrorTimeSpeed_;
std::chrono::steady_clock::time_point lastErrorTimeAmount_;
BttvEmotes bttv;
FfzEmotes ffz;
SeventvEmotes seventv_;
pajlada::Signals::SignalHolder signalHolder_;
};
@@ -13,10 +13,13 @@
#include "messages/Image.hpp"
#include "messages/Message.hpp"
#include "messages/MessageThread.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/chatterino/ChatterinoBadges.hpp"
#include "providers/colors/ColorProvider.hpp"
#include "providers/ffz/FfzBadges.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/seventv/SeventvBadges.hpp"
#include "providers/seventv/SeventvEmotes.hpp"
#include "providers/twitch/api/Helix.hpp"
#include "providers/twitch/ChannelPointReward.hpp"
#include "providers/twitch/PubSubActions.hpp"
@@ -1140,9 +1143,9 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
{
auto *app = getIApp();
const auto &globalBttvEmotes = app->getTwitch()->getBttvEmotes();
const auto &globalFfzEmotes = app->getTwitch()->getFfzEmotes();
const auto &globalSeventvEmotes = app->getTwitch()->getSeventvEmotes();
const auto *globalBttvEmotes = app->getBttvEmotes();
const auto *globalFfzEmotes = app->getFfzEmotes();
const auto *globalSeventvEmotes = app->getSeventvEmotes();
auto flags = MessageElementFlags();
auto emote = std::optional<EmotePtr>{};
@@ -1170,16 +1173,16 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
flags = MessageElementFlag::SevenTVEmote;
zeroWidth = emote.value()->zeroWidth;
}
else if ((emote = globalFfzEmotes.emote(name)))
else if ((emote = globalFfzEmotes->emote(name)))
{
flags = MessageElementFlag::FfzEmote;
}
else if ((emote = globalBttvEmotes.emote(name)))
else if ((emote = globalBttvEmotes->emote(name)))
{
flags = MessageElementFlag::BttvEmote;
zeroWidth = zeroWidthEmotes.contains(name.string);
}
else if ((emote = globalSeventvEmotes.globalEmote(name)))
else if ((emote = globalSeventvEmotes->globalEmote(name)))
{
flags = MessageElementFlag::SevenTVEmote;
zeroWidth = emote.value()->zeroWidth;