feat: add settings to toggle BTTV/FFZ global/channel emotes (#3935)
* feat: add settings to disable BTTV/FFZ global/channel emotes * docs: add changelog entry * fix: capitalize `BTTV` and `FFZ` * fix: rename and move settings
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "messages/ImageSet.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace {
|
||||
@@ -141,6 +142,12 @@ boost::optional<EmotePtr> BttvEmotes::emote(const EmoteName &name) const
|
||||
|
||||
void BttvEmotes::loadEmotes()
|
||||
{
|
||||
if (!Settings::instance().enableBTTVGlobalEmotes)
|
||||
{
|
||||
this->global_.set(EMPTY_EMOTE_MAP);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkRequest(QString(globalEmoteApiUrl))
|
||||
.timeout(30000)
|
||||
.onSuccess([this](auto result) -> Outcome {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "messages/Image.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace {
|
||||
@@ -181,6 +182,12 @@ boost::optional<EmotePtr> FfzEmotes::emote(const EmoteName &name) const
|
||||
|
||||
void FfzEmotes::loadEmotes()
|
||||
{
|
||||
if (!Settings::instance().enableFFZGlobalEmotes)
|
||||
{
|
||||
this->global_.set(EMPTY_EMOTE_MAP);
|
||||
return;
|
||||
}
|
||||
|
||||
QString url("https://api.frankerfacez.com/v1/set/global");
|
||||
|
||||
NetworkRequest(url)
|
||||
|
||||
@@ -197,6 +197,12 @@ void TwitchChannel::setLocalizedName(const QString &name)
|
||||
|
||||
void TwitchChannel::refreshBTTVChannelEmotes(bool manualRefresh)
|
||||
{
|
||||
if (!Settings::instance().enableBTTVChannelEmotes)
|
||||
{
|
||||
this->bttvEmotes_.set(EMPTY_EMOTE_MAP);
|
||||
return;
|
||||
}
|
||||
|
||||
BttvEmotes::loadChannel(
|
||||
weakOf<Channel>(this), this->roomId(), this->getLocalizedName(),
|
||||
[this, weak = weakOf<Channel>(this)](auto &&emoteMap) {
|
||||
@@ -209,6 +215,12 @@ void TwitchChannel::refreshBTTVChannelEmotes(bool manualRefresh)
|
||||
|
||||
void TwitchChannel::refreshFFZChannelEmotes(bool manualRefresh)
|
||||
{
|
||||
if (!Settings::instance().enableFFZChannelEmotes)
|
||||
{
|
||||
this->ffzEmotes_.set(EMPTY_EMOTE_MAP);
|
||||
return;
|
||||
}
|
||||
|
||||
FfzEmotes::loadChannel(
|
||||
weakOf<Channel>(this), this->roomId(),
|
||||
[this, weak = weakOf<Channel>(this)](auto &&emoteMap) {
|
||||
|
||||
@@ -52,8 +52,8 @@ void TwitchIrcServer::initialize(Settings &settings, Paths &paths)
|
||||
});
|
||||
});
|
||||
|
||||
this->bttv.loadEmotes();
|
||||
this->ffz.loadEmotes();
|
||||
this->reloadBTTVGlobalEmotes();
|
||||
this->reloadFFZGlobalEmotes();
|
||||
|
||||
/* Refresh all twitch channel's live status in bulk every 30 seconds after starting chatterino */
|
||||
QObject::connect(&this->bulkLiveStatusTimer_, &QTimer::timeout, [=] {
|
||||
@@ -468,4 +468,33 @@ const FfzEmotes &TwitchIrcServer::getFfzEmotes() const
|
||||
return this->ffz;
|
||||
}
|
||||
|
||||
void TwitchIrcServer::reloadBTTVGlobalEmotes()
|
||||
{
|
||||
this->bttv.loadEmotes();
|
||||
}
|
||||
|
||||
void TwitchIrcServer::reloadAllBTTVChannelEmotes()
|
||||
{
|
||||
this->forEachChannel([](const auto &chan) {
|
||||
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
|
||||
{
|
||||
channel->refreshBTTVChannelEmotes(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void TwitchIrcServer::reloadFFZGlobalEmotes()
|
||||
{
|
||||
this->ffz.loadEmotes();
|
||||
}
|
||||
|
||||
void TwitchIrcServer::reloadAllFFZChannelEmotes()
|
||||
{
|
||||
this->forEachChannel([](const auto &chan) {
|
||||
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
|
||||
{
|
||||
channel->refreshFFZChannelEmotes(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -33,6 +33,11 @@ public:
|
||||
|
||||
void bulkRefreshLiveStatus();
|
||||
|
||||
void reloadBTTVGlobalEmotes();
|
||||
void reloadAllBTTVChannelEmotes();
|
||||
void reloadFFZGlobalEmotes();
|
||||
void reloadAllFFZChannelEmotes();
|
||||
|
||||
Atomic<QString> lastUserThatWhisperedMe;
|
||||
|
||||
const ChannelPtr whispersChannel;
|
||||
|
||||
Reference in New Issue
Block a user