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
@@ -7,6 +7,8 @@
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "messages/MessageElement.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/irc/IrcChannel2.hpp"
#include "providers/irc/IrcServer.hpp"
#include "providers/twitch/api/Helix.hpp"
@@ -105,8 +107,8 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
const auto &acc = app->getAccounts()->twitch.getCurrent();
const auto &accemotes = *acc->accessEmotes();
const auto &bttvemotes = app->twitch->getBttvEmotes();
const auto &ffzemotes = app->twitch->getFfzEmotes();
const auto *bttvemotes = app->getBttvEmotes();
const auto *ffzemotes = app->getFfzEmotes();
auto flags = MessageElementFlags();
auto emote = std::optional<EmotePtr>{};
for (int i = 2; i < words.length(); i++)
@@ -122,14 +124,15 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
} // Twitch emote
{ // bttv/ffz emote
if ((emote = bttvemotes.emote({words[i]})))
if ((emote = bttvemotes->emote({words[i]})))
{
flags = MessageElementFlag::BttvEmote;
}
else if ((emote = ffzemotes.emote({words[i]})))
else if ((emote = ffzemotes->emote({words[i]})))
{
flags = MessageElementFlag::FfzEmote;
}
// TODO: Load 7tv global emotes
if (emote)
{
b.emplace<EmoteElement>(*emote, flags);
@@ -3,7 +3,10 @@
#include "Application.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/completion/sources/Helpers.hpp"
#include "providers/bttv/BttvEmotes.hpp"
#include "providers/emoji/Emojis.hpp"
#include "providers/ffz/FfzEmotes.hpp"
#include "providers/seventv/SeventvEmotes.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
@@ -127,15 +130,15 @@ void EmoteSource::initializeFromChannel(const Channel *channel)
}
}
if (auto bttvG = app->getTwitch()->getBttvEmotes().emotes())
if (auto bttvG = app->getBttvEmotes()->emotes())
{
addEmotes(emotes, *bttvG, "Global BetterTTV");
}
if (auto ffzG = app->getTwitch()->getFfzEmotes().emotes())
if (auto ffzG = app->getFfzEmotes()->emotes())
{
addEmotes(emotes, *ffzG, "Global FrankerFaceZ");
}
if (auto seventvG = app->getTwitch()->getSeventvEmotes().globalEmotes())
if (auto seventvG = app->getSeventvEmotes()->globalEmotes())
{
addEmotes(emotes, *seventvG, "Global 7TV");
}