chore: remove Singleton & replace getIApp with getApp (#5514)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "FfzBadges.hpp"
|
||||
#include "providers/ffz/FfzBadges.hpp"
|
||||
|
||||
#include "common/network/NetworkRequest.hpp"
|
||||
#include "common/network/NetworkResult.hpp"
|
||||
@@ -17,11 +17,6 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
void FfzBadges::initialize(Settings &settings, const Paths &paths)
|
||||
{
|
||||
this->load();
|
||||
}
|
||||
|
||||
std::vector<FfzBadges::Badge> FfzBadges::getUserBadges(const UserId &id)
|
||||
{
|
||||
std::vector<Badge> badges;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Aliases.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
#include "util/ThreadGuard.hpp"
|
||||
|
||||
@@ -19,10 +18,9 @@ namespace chatterino {
|
||||
struct Emote;
|
||||
using EmotePtr = std::shared_ptr<const Emote>;
|
||||
|
||||
class FfzBadges : public Singleton
|
||||
class FfzBadges
|
||||
{
|
||||
public:
|
||||
void initialize(Settings &settings, const Paths &paths) override;
|
||||
FfzBadges() = default;
|
||||
|
||||
struct Badge {
|
||||
@@ -33,9 +31,9 @@ public:
|
||||
std::vector<Badge> getUserBadges(const UserId &id);
|
||||
std::optional<Badge> getBadge(int badgeID) const;
|
||||
|
||||
private:
|
||||
void load();
|
||||
|
||||
private:
|
||||
std::shared_mutex mutex_;
|
||||
|
||||
// userBadges points a user ID to the list of badges they have
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace {
|
||||
|
||||
QString configPath()
|
||||
{
|
||||
return combinePath(getIApp()->getPaths().settingsDirectory, "irc.json");
|
||||
return combinePath(getApp()->getPaths().settingsDirectory, "irc.json");
|
||||
}
|
||||
|
||||
class Model : public SignalVectorModel<IrcServerData>
|
||||
|
||||
@@ -245,7 +245,7 @@ void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||
|
||||
if (highlighted && showInMentions)
|
||||
{
|
||||
getIApp()->getTwitch()->getMentionsChannel()->addMessage(
|
||||
getApp()->getTwitch()->getMentionsChannel()->addMessage(
|
||||
msg, MessageContext::Original);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Singleton.hpp"
|
||||
|
||||
#include <functional>
|
||||
|
||||
class QString;
|
||||
@@ -11,7 +9,7 @@ namespace chatterino {
|
||||
|
||||
class NetworkResult;
|
||||
|
||||
class SeventvAPI : public Singleton
|
||||
class SeventvAPI final
|
||||
{
|
||||
using ErrorCallback = std::function<void(const NetworkResult &)>;
|
||||
template <typename... T>
|
||||
@@ -19,7 +17,7 @@ class SeventvAPI : public Singleton
|
||||
|
||||
public:
|
||||
SeventvAPI() = default;
|
||||
~SeventvAPI() override = default;
|
||||
~SeventvAPI() = default;
|
||||
|
||||
SeventvAPI(const SeventvAPI &) = delete;
|
||||
SeventvAPI(SeventvAPI &&) = delete;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Aliases.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <QJsonObject>
|
||||
@@ -16,7 +15,7 @@ namespace chatterino {
|
||||
struct Emote;
|
||||
using EmotePtr = std::shared_ptr<const Emote>;
|
||||
|
||||
class SeventvBadges : public Singleton
|
||||
class SeventvBadges
|
||||
{
|
||||
public:
|
||||
// Return the badge, if any, that is assigned to the user
|
||||
|
||||
@@ -217,7 +217,7 @@ void SeventvEmotes::loadGlobalEmotes()
|
||||
|
||||
qCDebug(chatterinoSeventv) << "Loading 7TV Global Emotes";
|
||||
|
||||
getIApp()->getSeventvAPI()->getEmoteSet(
|
||||
getApp()->getSeventvAPI()->getEmoteSet(
|
||||
u"global"_s,
|
||||
[this](const auto &json) {
|
||||
QJsonArray parsedEmotes = json["emotes"].toArray();
|
||||
@@ -246,7 +246,7 @@ void SeventvEmotes::loadChannelEmotes(
|
||||
qCDebug(chatterinoSeventv)
|
||||
<< "Reloading 7TV Channel Emotes" << channelId << manualRefresh;
|
||||
|
||||
getIApp()->getSeventvAPI()->getUserByTwitchID(
|
||||
getApp()->getSeventvAPI()->getUserByTwitchID(
|
||||
channelId,
|
||||
[callback = std::move(callback), channel, channelId,
|
||||
manualRefresh](const auto &json) {
|
||||
@@ -405,7 +405,7 @@ void SeventvEmotes::getEmoteSet(
|
||||
{
|
||||
qCDebug(chatterinoSeventv) << "Loading 7TV Emote Set" << emoteSetId;
|
||||
|
||||
getIApp()->getSeventvAPI()->getEmoteSet(
|
||||
getApp()->getSeventvAPI()->getEmoteSet(
|
||||
emoteSetId,
|
||||
[callback = std::move(successCallback), emoteSetId](const auto &json) {
|
||||
auto parsedEmotes = json["emotes"].toArray();
|
||||
|
||||
@@ -348,7 +348,7 @@ void SeventvEventAPI::onUserUpdate(const Dispatch &dispatch)
|
||||
|
||||
void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
|
||||
{
|
||||
auto *badges = getIApp()->getSeventvBadges();
|
||||
auto *badges = getApp()->getSeventvBadges();
|
||||
switch (cosmetic.kind)
|
||||
{
|
||||
case CosmeticKind::Badge: {
|
||||
@@ -363,7 +363,7 @@ void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
|
||||
void SeventvEventAPI::onEntitlementCreate(
|
||||
const EntitlementCreateDeleteDispatch &entitlement)
|
||||
{
|
||||
auto *badges = getIApp()->getSeventvBadges();
|
||||
auto *badges = getApp()->getSeventvBadges();
|
||||
switch (entitlement.kind)
|
||||
{
|
||||
case CosmeticKind::Badge: {
|
||||
@@ -379,7 +379,7 @@ void SeventvEventAPI::onEntitlementCreate(
|
||||
void SeventvEventAPI::onEntitlementDelete(
|
||||
const EntitlementCreateDeleteDispatch &entitlement)
|
||||
{
|
||||
auto *badges = getIApp()->getSeventvBadges();
|
||||
auto *badges = getApp()->getSeventvBadges();
|
||||
switch (entitlement.kind)
|
||||
{
|
||||
case CosmeticKind::Badge: {
|
||||
|
||||
@@ -132,7 +132,7 @@ void updateReplyParticipatedStatus(const QVariantMap &tags,
|
||||
bool isNew)
|
||||
{
|
||||
const auto ¤tLogin =
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
|
||||
if (thread->subscribed())
|
||||
{
|
||||
@@ -390,7 +390,7 @@ std::vector<MessagePtr> parseNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||
{
|
||||
const auto linkColor = MessageColor(MessageColor::Link);
|
||||
const auto accountsLink = Link(Link::OpenAccountsPage, QString());
|
||||
const auto curUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
const auto curUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
const auto expirationText = QString("Login expired for user \"%1\"!")
|
||||
.arg(curUser->getUserName());
|
||||
const auto loginPromptText = QString("Try adding your account again.");
|
||||
@@ -692,7 +692,7 @@ void IrcMessageHandler::handlePrivMessage(Communi::IrcPrivateMessage *message,
|
||||
|
||||
if (twitchChannel != nullptr)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (message->tag("user-id") == currentUser->getUserId())
|
||||
{
|
||||
auto badgesTag = message->tag("badges");
|
||||
@@ -736,7 +736,7 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto chan = getIApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||
|
||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(chan.get());
|
||||
if (!twitchChannel)
|
||||
@@ -798,7 +798,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||
}
|
||||
|
||||
// get channel
|
||||
auto chan = getIApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||
|
||||
if (chan->isEmpty())
|
||||
{
|
||||
@@ -821,10 +821,10 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||
chan->addOrReplaceTimeout(std::move(clearChat.message));
|
||||
|
||||
// refresh all
|
||||
getIApp()->getWindows()->repaintVisibleChatWidgets(chan.get());
|
||||
getApp()->getWindows()->repaintVisibleChatWidgets(chan.get());
|
||||
if (getSettings()->hideModerated)
|
||||
{
|
||||
getIApp()->getWindows()->forceLayoutChannelViews();
|
||||
getApp()->getWindows()->forceLayoutChannelViews();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -843,7 +843,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
|
||||
}
|
||||
|
||||
// get channel
|
||||
auto chan = getIApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
|
||||
|
||||
if (chan->isEmpty())
|
||||
{
|
||||
@@ -875,7 +875,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
|
||||
|
||||
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
// set received emote-sets, used in TwitchAccount::loadUserstateEmotes
|
||||
bool emoteSetsChanged = currentUser->setUserstateEmoteSets(
|
||||
@@ -892,7 +892,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||
return;
|
||||
}
|
||||
|
||||
auto c = getIApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||
auto c = getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||
if (c->isEmpty())
|
||||
{
|
||||
return;
|
||||
@@ -927,7 +927,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||
void IrcMessageHandler::handleGlobalUserStateMessage(
|
||||
Communi::IrcMessage *message)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
// set received emote-sets, this time used to initially load emotes
|
||||
// NOTE: this should always return true unless we reconnect
|
||||
@@ -947,7 +947,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
|
||||
|
||||
args.isReceivedWhisper = true;
|
||||
|
||||
auto *c = getIApp()->getTwitch()->getWhispersChannel().get();
|
||||
auto *c = getApp()->getTwitch()->getWhispersChannel().get();
|
||||
|
||||
TwitchMessageBuilder builder(
|
||||
c, ircMessage, args,
|
||||
@@ -963,11 +963,11 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
|
||||
MessagePtr message = builder.build();
|
||||
builder.triggerHighlights();
|
||||
|
||||
getIApp()->getTwitch()->setLastUserThatWhisperedMe(builder.userName);
|
||||
getApp()->getTwitch()->setLastUserThatWhisperedMe(builder.userName);
|
||||
|
||||
if (message->flags.has(MessageFlag::ShowInMentions))
|
||||
{
|
||||
getIApp()->getTwitch()->getMentionsChannel()->addMessage(
|
||||
getApp()->getTwitch()->getMentionsChannel()->addMessage(
|
||||
message, MessageContext::Original);
|
||||
}
|
||||
|
||||
@@ -979,13 +979,12 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
|
||||
|
||||
if (getSettings()->inlineWhispers &&
|
||||
!(getSettings()->streamerModeSuppressInlineWhispers &&
|
||||
getIApp()->getStreamerMode()->isEnabled()))
|
||||
getApp()->getStreamerMode()->isEnabled()))
|
||||
{
|
||||
getIApp()->getTwitchAbstract()->forEachChannel(
|
||||
[&message, overrideFlags](ChannelPtr channel) {
|
||||
channel->addMessage(message, MessageContext::Repost,
|
||||
overrideFlags);
|
||||
});
|
||||
getApp()->getTwitchAbstract()->forEachChannel([&message, overrideFlags](
|
||||
ChannelPtr channel) {
|
||||
channel->addMessage(message, MessageContext::Repost, overrideFlags);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,7 +1117,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||
{
|
||||
// Notice wasn't targeted at a single channel, send to all twitch
|
||||
// channels
|
||||
getIApp()->getTwitch()->forEachChannelAndSpecialChannels(
|
||||
getApp()->getTwitch()->forEachChannelAndSpecialChannels(
|
||||
[msg](const auto &c) {
|
||||
c->addMessage(msg, MessageContext::Original);
|
||||
});
|
||||
@@ -1127,7 +1126,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||
}
|
||||
|
||||
auto channel =
|
||||
getIApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||
getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||
|
||||
if (channel->isEmpty())
|
||||
{
|
||||
@@ -1210,7 +1209,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||
|
||||
void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||
{
|
||||
auto channel = getIApp()->getTwitchAbstract()->getChannelOrEmpty(
|
||||
auto channel = getApp()->getTwitchAbstract()->getChannelOrEmpty(
|
||||
message->parameter(0).remove(0, 1));
|
||||
|
||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
@@ -1220,7 +1219,7 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||
}
|
||||
|
||||
if (message->nick() ==
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName())
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserName())
|
||||
{
|
||||
twitchChannel->addSystemMessage("joined channel");
|
||||
twitchChannel->joined.invoke();
|
||||
@@ -1233,7 +1232,7 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||
|
||||
void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
||||
{
|
||||
auto channel = getIApp()->getTwitchAbstract()->getChannelOrEmpty(
|
||||
auto channel = getApp()->getTwitchAbstract()->getChannelOrEmpty(
|
||||
message->parameter(0).remove(0, 1));
|
||||
|
||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
@@ -1243,7 +1242,7 @@ void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
||||
}
|
||||
|
||||
const auto selfAccountName =
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
if (message->nick() != selfAccountName &&
|
||||
getSettings()->showParts.getValue())
|
||||
{
|
||||
@@ -1296,7 +1295,7 @@ void IrcMessageHandler::setSimilarityFlags(const MessagePtr &message,
|
||||
{
|
||||
bool isMyself =
|
||||
message->loginName ==
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
bool hideMyself = getSettings()->hideSimilarMyself;
|
||||
|
||||
if (isMyself && !hideMyself)
|
||||
|
||||
@@ -109,7 +109,7 @@ void TwitchAccount::loadBlocks()
|
||||
this->ignoresUserIds_.clear();
|
||||
|
||||
getHelix()->loadBlocks(
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->userId_,
|
||||
getApp()->getAccounts()->twitch.getCurrent()->userId_,
|
||||
[this](const std::vector<HelixBlock> &blocks) {
|
||||
assertInGuiThread();
|
||||
|
||||
@@ -325,7 +325,7 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
|
||||
|
||||
emoteSet->emotes.push_back(TwitchEmote{id, code});
|
||||
|
||||
auto emote = getIApp()
|
||||
auto emote = getApp()
|
||||
->getEmotes()
|
||||
->getTwitchEmotes()
|
||||
->getOrCreateEmote(id, code);
|
||||
@@ -493,7 +493,7 @@ void TwitchAccount::loadSeventvUserID()
|
||||
return;
|
||||
}
|
||||
|
||||
auto *seventv = getIApp()->getSeventvAPI();
|
||||
auto *seventv = getApp()->getSeventvAPI();
|
||||
if (!seventv)
|
||||
{
|
||||
qCWarning(chatterinoSeventv)
|
||||
|
||||
@@ -91,7 +91,7 @@ TwitchChannel::TwitchChannel(const QString &name)
|
||||
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
|
||||
|
||||
this->bSignals_.emplace_back(
|
||||
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
|
||||
getApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
|
||||
this->setMod(false);
|
||||
this->refreshPubSub();
|
||||
}));
|
||||
@@ -143,18 +143,18 @@ TwitchChannel::TwitchChannel(const QString &name)
|
||||
|
||||
TwitchChannel::~TwitchChannel()
|
||||
{
|
||||
getIApp()->getTwitch()->dropSeventvChannel(this->seventvUserID_,
|
||||
this->seventvEmoteSetID_);
|
||||
getApp()->getTwitch()->dropSeventvChannel(this->seventvUserID_,
|
||||
this->seventvEmoteSetID_);
|
||||
|
||||
if (getIApp()->getTwitch()->getBTTVLiveUpdates())
|
||||
if (getApp()->getTwitch()->getBTTVLiveUpdates())
|
||||
{
|
||||
getIApp()->getTwitch()->getBTTVLiveUpdates()->partChannel(
|
||||
getApp()->getTwitch()->getBTTVLiveUpdates()->partChannel(
|
||||
this->roomId());
|
||||
}
|
||||
|
||||
if (getIApp()->getTwitch()->getSeventvEventAPI())
|
||||
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||
{
|
||||
getIApp()->getTwitch()->getSeventvEventAPI()->unsubscribeTwitchChannel(
|
||||
getApp()->getTwitch()->getSeventvEventAPI()->unsubscribeTwitchChannel(
|
||||
this->roomId());
|
||||
}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
|
||||
<< "] Channel point reward added:" << reward.id << ","
|
||||
<< reward.title << "," << reward.isUserInputRequired;
|
||||
|
||||
auto *server = getIApp()->getTwitch();
|
||||
auto *server = getApp()->getTwitch();
|
||||
auto it = std::remove_if(
|
||||
this->waitingRedemptions_.begin(), this->waitingRedemptions_.end(),
|
||||
[&](const QueuedRedemption &msg) {
|
||||
@@ -426,7 +426,7 @@ void TwitchChannel::onLiveStatusChanged(bool isLive, bool isInitialUpdate)
|
||||
qCDebug(chatterinoTwitch).nospace().noquote()
|
||||
<< "[TwitchChannel " << this->getName() << "] Online";
|
||||
|
||||
getIApp()->getNotifications()->notifyTwitchChannelLive({
|
||||
getApp()->getNotifications()->notifyTwitchChannelLive({
|
||||
.channelId = this->roomId(),
|
||||
.channelName = this->getName(),
|
||||
.displayName = this->getDisplayName(),
|
||||
@@ -452,7 +452,7 @@ void TwitchChannel::onLiveStatusChanged(bool isLive, bool isInitialUpdate)
|
||||
&builder);
|
||||
this->addMessage(builder.release(), MessageContext::Original);
|
||||
|
||||
getIApp()->getNotifications()->notifyTwitchChannelOffline(
|
||||
getApp()->getNotifications()->notifyTwitchChannelOffline(
|
||||
this->roomId());
|
||||
}
|
||||
};
|
||||
@@ -509,7 +509,7 @@ void TwitchChannel::showLoginMessage()
|
||||
{
|
||||
const auto linkColor = MessageColor(MessageColor::Link);
|
||||
const auto accountsLink = Link(Link::OpenAccountsPage, QString());
|
||||
const auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
const auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
const auto expirationText =
|
||||
QStringLiteral("You need to log in to send messages. You can link your "
|
||||
"Twitch account");
|
||||
@@ -532,7 +532,7 @@ void TwitchChannel::showLoginMessage()
|
||||
|
||||
void TwitchChannel::roomIdChanged()
|
||||
{
|
||||
if (getIApp()->isTest())
|
||||
if (getApp()->isTest())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -544,7 +544,7 @@ void TwitchChannel::roomIdChanged()
|
||||
this->refreshSevenTVChannelEmotes(false);
|
||||
this->joinBttvChannel();
|
||||
this->listenSevenTVCosmetics();
|
||||
getIApp()->getTwitchLiveController()->add(
|
||||
getApp()->getTwitchLiveController()->add(
|
||||
std::dynamic_pointer_cast<TwitchChannel>(shared_from_this()));
|
||||
}
|
||||
|
||||
@@ -710,7 +710,7 @@ void TwitchChannel::setStaff(bool value)
|
||||
|
||||
bool TwitchChannel::isBroadcaster() const
|
||||
{
|
||||
auto *app = getIApp();
|
||||
auto *app = getApp();
|
||||
|
||||
return this->getName() ==
|
||||
app->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
@@ -728,7 +728,7 @@ bool TwitchChannel::canReconnect() const
|
||||
|
||||
void TwitchChannel::reconnect()
|
||||
{
|
||||
getIApp()->getTwitchAbstract()->connect();
|
||||
getApp()->getTwitchAbstract()->connect();
|
||||
}
|
||||
|
||||
QString TwitchChannel::getCurrentStreamID() const
|
||||
@@ -753,7 +753,7 @@ void TwitchChannel::setRoomId(const QString &id)
|
||||
{
|
||||
*this->roomID_.access() = id;
|
||||
// This is intended for tests and benchmarks. See comment in constructor.
|
||||
if (!getIApp()->isTest())
|
||||
if (!getApp()->isTest())
|
||||
{
|
||||
this->roomIdChanged();
|
||||
this->loadRecentMessages();
|
||||
@@ -854,17 +854,17 @@ const QString &TwitchChannel::seventvEmoteSetID() const
|
||||
|
||||
void TwitchChannel::joinBttvChannel() const
|
||||
{
|
||||
if (getIApp()->getTwitch()->getBTTVLiveUpdates())
|
||||
if (getApp()->getTwitch()->getBTTVLiveUpdates())
|
||||
{
|
||||
const auto currentAccount =
|
||||
getIApp()->getAccounts()->twitch.getCurrent();
|
||||
getApp()->getAccounts()->twitch.getCurrent();
|
||||
QString userName;
|
||||
if (currentAccount && !currentAccount->isAnon())
|
||||
{
|
||||
userName = currentAccount->getUserName();
|
||||
}
|
||||
getIApp()->getTwitch()->getBTTVLiveUpdates()->joinChannel(
|
||||
this->roomId(), userName);
|
||||
getApp()->getTwitch()->getBTTVLiveUpdates()->joinChannel(this->roomId(),
|
||||
userName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,14 +1012,14 @@ void TwitchChannel::updateSeventvData(const QString &newUserID,
|
||||
this->seventvUserID_ = newUserID;
|
||||
this->seventvEmoteSetID_ = newEmoteSetID;
|
||||
runInGuiThread([this, oldUserID, oldEmoteSetID]() {
|
||||
if (getIApp()->getTwitch()->getSeventvEventAPI())
|
||||
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||
{
|
||||
getIApp()->getTwitch()->getSeventvEventAPI()->subscribeUser(
|
||||
getApp()->getTwitch()->getSeventvEventAPI()->subscribeUser(
|
||||
this->seventvUserID_, this->seventvEmoteSetID_);
|
||||
|
||||
if (oldUserID || oldEmoteSetID)
|
||||
{
|
||||
getIApp()->getTwitch()->dropSeventvChannel(
|
||||
getApp()->getTwitch()->dropSeventvChannel(
|
||||
oldUserID.value_or(QString()),
|
||||
oldEmoteSetID.value_or(QString()));
|
||||
}
|
||||
@@ -1215,7 +1215,7 @@ void TwitchChannel::loadRecentMessages()
|
||||
tc->addRecentChatter(msg->displayName);
|
||||
}
|
||||
|
||||
getIApp()->getTwitch()->getMentionsChannel()->fillInMissingMessages(
|
||||
getApp()->getTwitch()->getMentionsChannel()->fillInMissingMessages(
|
||||
msgs);
|
||||
},
|
||||
[weak]() {
|
||||
@@ -1303,7 +1303,7 @@ void TwitchChannel::loadRecentMessagesReconnect()
|
||||
|
||||
void TwitchChannel::refreshPubSub()
|
||||
{
|
||||
if (getIApp()->isTest())
|
||||
if (getApp()->isTest())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1314,17 +1314,17 @@ void TwitchChannel::refreshPubSub()
|
||||
return;
|
||||
}
|
||||
|
||||
auto currentAccount = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentAccount = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
getIApp()->getTwitchPubSub()->setAccount(currentAccount);
|
||||
getApp()->getTwitchPubSub()->setAccount(currentAccount);
|
||||
|
||||
getIApp()->getTwitchPubSub()->listenToChannelModerationActions(roomId);
|
||||
getApp()->getTwitchPubSub()->listenToChannelModerationActions(roomId);
|
||||
if (this->hasModRights())
|
||||
{
|
||||
getIApp()->getTwitchPubSub()->listenToAutomod(roomId);
|
||||
getIApp()->getTwitchPubSub()->listenToLowTrustUsers(roomId);
|
||||
getApp()->getTwitchPubSub()->listenToAutomod(roomId);
|
||||
getApp()->getTwitchPubSub()->listenToLowTrustUsers(roomId);
|
||||
}
|
||||
getIApp()->getTwitchPubSub()->listenToChannelPointRewards(roomId);
|
||||
getApp()->getTwitchPubSub()->listenToChannelPointRewards(roomId);
|
||||
}
|
||||
|
||||
void TwitchChannel::refreshChatters()
|
||||
@@ -1350,7 +1350,7 @@ void TwitchChannel::refreshChatters()
|
||||
// Get chatter list via helix api
|
||||
getHelix()->getChatters(
|
||||
this->roomId(),
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
||||
MAX_CHATTERS_TO_FETCH,
|
||||
[this, weak = weakOf<Channel>(this)](auto result) {
|
||||
if (auto shared = weak.lock())
|
||||
@@ -1710,7 +1710,7 @@ std::vector<FfzBadges::Badge> TwitchChannel::ffzChannelBadges(
|
||||
|
||||
std::vector<FfzBadges::Badge> badges;
|
||||
|
||||
const auto *ffzBadges = getIApp()->getFfzBadges();
|
||||
const auto *ffzBadges = getApp()->getFfzBadges();
|
||||
|
||||
for (const auto &badgeID : it->second)
|
||||
{
|
||||
@@ -1769,7 +1769,7 @@ void TwitchChannel::updateSevenTVActivity()
|
||||
QStringLiteral("https://7tv.io/v3/users/%1/presences");
|
||||
|
||||
const auto currentSeventvUserID =
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getSeventvUserID();
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getSeventvUserID();
|
||||
if (currentSeventvUserID.isEmpty())
|
||||
{
|
||||
return;
|
||||
@@ -1791,7 +1791,7 @@ void TwitchChannel::updateSevenTVActivity()
|
||||
|
||||
qCDebug(chatterinoSeventv) << "Sending activity in" << this->getName();
|
||||
|
||||
getIApp()->getSeventvAPI()->updatePresence(
|
||||
getApp()->getSeventvAPI()->updatePresence(
|
||||
this->roomId(), currentSeventvUserID,
|
||||
[chan = weakOf<Channel>(this)]() {
|
||||
const auto self =
|
||||
@@ -1811,9 +1811,9 @@ void TwitchChannel::updateSevenTVActivity()
|
||||
|
||||
void TwitchChannel::listenSevenTVCosmetics() const
|
||||
{
|
||||
if (getIApp()->getTwitch()->getSeventvEventAPI())
|
||||
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||
{
|
||||
getIApp()->getTwitch()->getSeventvEventAPI()->subscribeTwitchChannel(
|
||||
getApp()->getTwitch()->getSeventvEventAPI()->subscribeTwitchChannel(
|
||||
this->roomId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ void sendHelixMessage(const std::shared_ptr<TwitchChannel> &channel,
|
||||
{
|
||||
.broadcasterID = broadcasterID,
|
||||
.senderID =
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserId(),
|
||||
.message = message,
|
||||
.replyParentMessageID = replyParentId,
|
||||
},
|
||||
@@ -167,7 +167,7 @@ TwitchIrcServer::TwitchIrcServer()
|
||||
|
||||
void TwitchIrcServer::initialize()
|
||||
{
|
||||
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this]() {
|
||||
getApp()->getAccounts()->twitch.currentUserChanged.connect([this]() {
|
||||
postToThread([this] {
|
||||
this->connect();
|
||||
});
|
||||
@@ -182,7 +182,7 @@ void TwitchIrcServer::initializeConnection(IrcConnection *connection,
|
||||
ConnectionType type)
|
||||
{
|
||||
std::shared_ptr<TwitchAccount> account =
|
||||
getIApp()->getAccounts()->twitch.getCurrent();
|
||||
getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
qCDebug(chatterinoTwitch) << "logging in as" << account->getUserName();
|
||||
|
||||
@@ -690,7 +690,7 @@ void TwitchIrcServer::setLastUserThatWhisperedMe(const QString &user)
|
||||
|
||||
void TwitchIrcServer::reloadBTTVGlobalEmotes()
|
||||
{
|
||||
getIApp()->getBttvEmotes()->loadEmotes();
|
||||
getApp()->getBttvEmotes()->loadEmotes();
|
||||
}
|
||||
|
||||
void TwitchIrcServer::reloadAllBTTVChannelEmotes()
|
||||
@@ -705,7 +705,7 @@ void TwitchIrcServer::reloadAllBTTVChannelEmotes()
|
||||
|
||||
void TwitchIrcServer::reloadFFZGlobalEmotes()
|
||||
{
|
||||
getIApp()->getFfzEmotes()->loadEmotes();
|
||||
getApp()->getFfzEmotes()->loadEmotes();
|
||||
}
|
||||
|
||||
void TwitchIrcServer::reloadAllFFZChannelEmotes()
|
||||
@@ -720,7 +720,7 @@ void TwitchIrcServer::reloadAllFFZChannelEmotes()
|
||||
|
||||
void TwitchIrcServer::reloadSevenTVGlobalEmotes()
|
||||
{
|
||||
getIApp()->getSeventvEmotes()->loadGlobalEmotes();
|
||||
getApp()->getSeventvEmotes()->loadGlobalEmotes();
|
||||
}
|
||||
|
||||
void TwitchIrcServer::reloadAllSevenTVChannelEmotes()
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace {
|
||||
const QString &originalMessage,
|
||||
int messageOffset)
|
||||
{
|
||||
auto *app = getIApp();
|
||||
auto *app = getApp();
|
||||
if (!emote.contains(':'))
|
||||
{
|
||||
return;
|
||||
@@ -167,7 +167,7 @@ namespace {
|
||||
}
|
||||
|
||||
if (auto globalBadge =
|
||||
getIApp()->getTwitchBadges()->badge(badge.key_, badge.value_))
|
||||
getApp()->getTwitchBadges()->badge(badge.key_, badge.value_))
|
||||
{
|
||||
return globalBadge;
|
||||
}
|
||||
@@ -673,7 +673,7 @@ void TwitchMessageBuilder::addWords(
|
||||
// 1. Add text before the emote
|
||||
QString preText = word.left(currentTwitchEmote.start - cursor);
|
||||
for (auto &variant :
|
||||
getIApp()->getEmotes()->getEmojis()->parse(preText))
|
||||
getApp()->getEmotes()->getEmojis()->parse(preText))
|
||||
{
|
||||
boost::apply_visitor(
|
||||
[&](auto &&arg) {
|
||||
@@ -693,7 +693,7 @@ void TwitchMessageBuilder::addWords(
|
||||
}
|
||||
|
||||
// split words
|
||||
for (auto &variant : getIApp()->getEmotes()->getEmojis()->parse(word))
|
||||
for (auto &variant : getApp()->getEmotes()->getEmojis()->parse(word))
|
||||
{
|
||||
boost::apply_visitor(
|
||||
[&](auto &&arg) {
|
||||
@@ -937,7 +937,7 @@ void TwitchMessageBuilder::parseThread()
|
||||
|
||||
void TwitchMessageBuilder::parseUsernameColor()
|
||||
{
|
||||
const auto *userData = getIApp()->getUserData();
|
||||
const auto *userData = getApp()->getUserData();
|
||||
assert(userData != nullptr);
|
||||
|
||||
if (const auto &user = userData->getUser(this->userId_))
|
||||
@@ -991,7 +991,7 @@ void TwitchMessageBuilder::parseUsername()
|
||||
}
|
||||
|
||||
// Update current user color if this is our message
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (this->ircMessage->nick() == currentUser->getUserName())
|
||||
{
|
||||
currentUser->setColor(this->usernameColor_);
|
||||
@@ -1000,7 +1000,7 @@ void TwitchMessageBuilder::parseUsername()
|
||||
|
||||
void TwitchMessageBuilder::appendUsername()
|
||||
{
|
||||
auto *app = getIApp();
|
||||
auto *app = getApp();
|
||||
|
||||
QString username = this->userName;
|
||||
this->message().loginName = username;
|
||||
@@ -1256,7 +1256,7 @@ void TwitchMessageBuilder::processIgnorePhrases(
|
||||
|
||||
Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
|
||||
{
|
||||
auto *app = getIApp();
|
||||
auto *app = getApp();
|
||||
|
||||
const auto *globalBttvEmotes = app->getBttvEmotes();
|
||||
const auto *globalFfzEmotes = app->getFfzEmotes();
|
||||
@@ -1410,8 +1410,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||
|
||||
void TwitchMessageBuilder::appendChatterinoBadges()
|
||||
{
|
||||
if (auto badge =
|
||||
getIApp()->getChatterinoBadges()->getBadge({this->userId_}))
|
||||
if (auto badge = getApp()->getChatterinoBadges()->getBadge({this->userId_}))
|
||||
{
|
||||
this->emplace<BadgeElement>(*badge,
|
||||
MessageElementFlag::BadgeChatterino);
|
||||
@@ -1421,7 +1420,7 @@ void TwitchMessageBuilder::appendChatterinoBadges()
|
||||
void TwitchMessageBuilder::appendFfzBadges()
|
||||
{
|
||||
for (const auto &badge :
|
||||
getIApp()->getFfzBadges()->getUserBadges({this->userId_}))
|
||||
getApp()->getFfzBadges()->getUserBadges({this->userId_}))
|
||||
{
|
||||
this->emplace<FfzBadgeElement>(
|
||||
badge.emote, MessageElementFlag::BadgeFfz, badge.color);
|
||||
@@ -1442,7 +1441,7 @@ void TwitchMessageBuilder::appendFfzBadges()
|
||||
|
||||
void TwitchMessageBuilder::appendSeventvBadges()
|
||||
{
|
||||
if (auto badge = getIApp()->getSeventvBadges()->getBadge({this->userId_}))
|
||||
if (auto badge = getApp()->getSeventvBadges()->getBadge({this->userId_}))
|
||||
{
|
||||
this->emplace<BadgeElement>(*badge, MessageElementFlag::BadgeSevenTV);
|
||||
}
|
||||
@@ -1585,7 +1584,7 @@ void TwitchMessageBuilder::appendChannelPointRewardMessage(
|
||||
if (reward.id == "CELEBRATION")
|
||||
{
|
||||
const auto emotePtr =
|
||||
getIApp()->getEmotes()->getTwitchEmotes()->getOrCreateEmote(
|
||||
getApp()->getEmotes()->getTwitchEmotes()->getOrCreateEmote(
|
||||
EmoteId{reward.emoteId}, EmoteName{reward.emoteName});
|
||||
builder->emplace<EmoteElement>(emotePtr,
|
||||
MessageElementFlag::ChannelPointReward,
|
||||
@@ -2060,7 +2059,7 @@ std::pair<MessagePtr, MessagePtr> TwitchMessageBuilder::makeAutomodMessage(
|
||||
// Normally highlights would be checked & triggered during the builder parse steps
|
||||
// and when the message is added to the channel
|
||||
// We do this a bit weird since the message comes in from PubSub and not the normal message route
|
||||
auto [highlighted, highlightResult] = getIApp()->getHighlights()->check(
|
||||
auto [highlighted, highlightResult] = getApp()->getHighlights()->check(
|
||||
{}, {}, action.target.login, action.message, message2->flags);
|
||||
if (highlighted)
|
||||
{
|
||||
@@ -2256,7 +2255,7 @@ std::pair<MessagePtr, MessagePtr> TwitchMessageBuilder::makeLowTrustUserMessage(
|
||||
else
|
||||
{
|
||||
const auto emotePtr =
|
||||
getIApp()->getEmotes()->getTwitchEmotes()->getOrCreateEmote(
|
||||
getApp()->getEmotes()->getTwitchEmotes()->getOrCreateEmote(
|
||||
EmoteId{fragment.emoteID}, EmoteName{fragment.text});
|
||||
builder2.emplace<EmoteElement>(
|
||||
emotePtr, MessageElementFlag::TwitchEmote, MessageColor::Text);
|
||||
|
||||
Reference in New Issue
Block a user