chore: remove Singleton & replace getIApp with getApp (#5514)
This commit is contained in:
@@ -220,7 +220,7 @@ QString marker(const CommandContext &ctx)
|
||||
}
|
||||
|
||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||
if (getIApp()->getAccounts()->twitch.getCurrent()->isAnon())
|
||||
if (getApp()->getAccounts()->twitch.getCurrent()->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
"You need to be logged in to create stream markers!");
|
||||
@@ -367,7 +367,7 @@ QString popup(const CommandContext &ctx)
|
||||
if (target.isEmpty())
|
||||
{
|
||||
auto *currentPage =
|
||||
dynamic_cast<SplitContainer *>(getIApp()
|
||||
dynamic_cast<SplitContainer *>(getApp()
|
||||
->getWindows()
|
||||
->getMainWindow()
|
||||
.getNotebook()
|
||||
@@ -388,9 +388,8 @@ QString popup(const CommandContext &ctx)
|
||||
}
|
||||
|
||||
// Open channel passed as argument in a popup
|
||||
auto targetChannel =
|
||||
getIApp()->getTwitchAbstract()->getOrAddChannel(target);
|
||||
getIApp()->getWindows()->openInPopup(targetChannel);
|
||||
auto targetChannel = getApp()->getTwitchAbstract()->getOrAddChannel(target);
|
||||
getApp()->getWindows()->openInPopup(targetChannel);
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -399,7 +398,7 @@ QString clearmessages(const CommandContext &ctx)
|
||||
{
|
||||
(void)ctx;
|
||||
|
||||
auto *currentPage = getIApp()
|
||||
auto *currentPage = getApp()
|
||||
->getWindows()
|
||||
->getLastSelectedWindow()
|
||||
->getNotebook()
|
||||
@@ -531,7 +530,7 @@ QString sendRawMessage(const CommandContext &ctx)
|
||||
|
||||
if (ctx.channel->isTwitchChannel())
|
||||
{
|
||||
getIApp()->getTwitchAbstract()->sendRawMessage(
|
||||
getApp()->getTwitchAbstract()->sendRawMessage(
|
||||
ctx.words.mid(1).join(" "));
|
||||
}
|
||||
else
|
||||
@@ -565,7 +564,7 @@ QString injectFakeMessage(const CommandContext &ctx)
|
||||
}
|
||||
|
||||
auto ircText = ctx.words.mid(1).join(" ");
|
||||
getIApp()->getTwitchAbstract()->addFakeMessage(ircText);
|
||||
getApp()->getTwitchAbstract()->addFakeMessage(ircText);
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -634,7 +633,7 @@ QString unstableSetUserClientSideColor(const CommandContext &ctx)
|
||||
|
||||
auto color = ctx.words.value(2);
|
||||
|
||||
getIApp()->getUserData()->setUserColor(userID, color);
|
||||
getApp()->getUserData()->setUserColor(userID, color);
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -664,7 +663,7 @@ QString openUsercard(const CommandContext &ctx)
|
||||
stripChannelName(channelName);
|
||||
|
||||
ChannelPtr channelTemp =
|
||||
getIApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||
getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
|
||||
|
||||
if (channelTemp->isEmpty())
|
||||
{
|
||||
@@ -679,7 +678,7 @@ QString openUsercard(const CommandContext &ctx)
|
||||
|
||||
// try to link to current split if possible
|
||||
Split *currentSplit = nullptr;
|
||||
auto *currentPage = dynamic_cast<SplitContainer *>(getIApp()
|
||||
auto *currentPage = dynamic_cast<SplitContainer *>(getApp()
|
||||
->getWindows()
|
||||
->getMainWindow()
|
||||
.getNotebook()
|
||||
@@ -695,7 +694,7 @@ QString openUsercard(const CommandContext &ctx)
|
||||
{
|
||||
// not possible to use current split, try searching for one
|
||||
const auto ¬ebook =
|
||||
getIApp()->getWindows()->getMainWindow().getNotebook();
|
||||
getApp()->getWindows()->getMainWindow().getNotebook();
|
||||
auto count = notebook.getPageCount();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ QString addModerator(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage("You must be logged in to mod someone!");
|
||||
|
||||
@@ -32,7 +32,7 @@ QString addVIP(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage("You must be logged in to VIP someone!");
|
||||
|
||||
@@ -50,7 +50,7 @@ QString sendAnnouncementColor(const CommandContext &ctx,
|
||||
return "";
|
||||
}
|
||||
|
||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (user->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
|
||||
@@ -141,7 +141,7 @@ QString sendBan(const CommandContext &ctx)
|
||||
|
||||
assert(!actions.value().empty());
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage("You must be logged in to ban someone!");
|
||||
@@ -252,7 +252,7 @@ QString sendBanById(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
channel->addSystemMessage("You must be logged in to ban someone!");
|
||||
@@ -292,7 +292,7 @@ QString sendTimeout(const CommandContext &ctx)
|
||||
|
||||
assert(!actions.value().empty());
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
|
||||
@@ -36,7 +36,7 @@ QString blockUser(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
@@ -52,7 +52,7 @@ QString blockUser(const CommandContext &ctx)
|
||||
target,
|
||||
[currentUser, channel{ctx.channel},
|
||||
target](const HelixUser &targetUser) {
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
||||
getApp()->getAccounts()->twitch.getCurrent()->blockUser(
|
||||
targetUser.id, nullptr,
|
||||
[channel, target, targetUser] {
|
||||
channel->addSystemMessage(
|
||||
@@ -109,7 +109,7 @@ QString unblockUser(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
@@ -124,7 +124,7 @@ QString unblockUser(const CommandContext &ctx)
|
||||
getHelix()->getUserByName(
|
||||
target,
|
||||
[currentUser, channel{ctx.channel}, target](const auto &targetUser) {
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->unblockUser(
|
||||
getApp()->getAccounts()->twitch.getCurrent()->unblockUser(
|
||||
targetUser.id, nullptr,
|
||||
[channel, target, targetUser] {
|
||||
channel->addSystemMessage(
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace chatterino::commands {
|
||||
|
||||
QString emoteOnly(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -130,7 +130,7 @@ QString emoteOnly(const CommandContext &ctx)
|
||||
|
||||
QString emoteOnlyOff(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -158,7 +158,7 @@ QString emoteOnlyOff(const CommandContext &ctx)
|
||||
|
||||
QString subscribers(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -188,7 +188,7 @@ QString subscribers(const CommandContext &ctx)
|
||||
|
||||
QString subscribersOff(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -218,7 +218,7 @@ QString subscribersOff(const CommandContext &ctx)
|
||||
|
||||
QString slow(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -265,7 +265,7 @@ QString slow(const CommandContext &ctx)
|
||||
|
||||
QString slowOff(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -294,7 +294,7 @@ QString slowOff(const CommandContext &ctx)
|
||||
|
||||
QString followers(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -342,7 +342,7 @@ QString followers(const CommandContext &ctx)
|
||||
|
||||
QString followersOff(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -372,7 +372,7 @@ QString followersOff(const CommandContext &ctx)
|
||||
|
||||
QString uniqueChat(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
@@ -402,7 +402,7 @@ QString uniqueChat(const CommandContext &ctx)
|
||||
|
||||
QString uniqueChatOff(const CommandContext &ctx)
|
||||
{
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(P_NOT_LOGGED_IN);
|
||||
|
||||
@@ -77,7 +77,7 @@ QString chatters(const CommandContext &ctx)
|
||||
// Refresh chatter list via helix api for mods
|
||||
getHelix()->getChatters(
|
||||
ctx.twitchChannel->roomId(),
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(), 1,
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserId(), 1,
|
||||
[channel{ctx.channel}](auto result) {
|
||||
channel->addSystemMessage(QString("Chatter count: %1.")
|
||||
.arg(localizeNumbers(result.total)));
|
||||
@@ -106,7 +106,7 @@ QString testChatters(const CommandContext &ctx)
|
||||
|
||||
getHelix()->getChatters(
|
||||
ctx.twitchChannel->roomId(),
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(), 5000,
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserId(), 5000,
|
||||
[channel{ctx.channel}, twitchChannel{ctx.twitchChannel}](auto result) {
|
||||
QStringList entries;
|
||||
for (const auto &username : result.chatters)
|
||||
|
||||
@@ -21,7 +21,7 @@ QString deleteMessages(TwitchChannel *twitchChannel, const QString &messageID)
|
||||
{
|
||||
const auto *commandName = messageID.isEmpty() ? "/clear" : "/delete";
|
||||
|
||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||
if (user->isAnon())
|
||||
|
||||
@@ -81,7 +81,7 @@ QString getVIPs(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
|
||||
@@ -136,7 +136,7 @@ QString startRaid(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage("You must be logged in to start a raid!");
|
||||
@@ -192,7 +192,7 @@ QString cancelRaid(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
|
||||
@@ -32,7 +32,7 @@ QString removeModerator(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
|
||||
@@ -34,7 +34,7 @@ QString removeVIP(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
|
||||
@@ -92,7 +92,7 @@ QString formatWhisperError(HelixWhisperError error, const QString &message)
|
||||
|
||||
bool appendWhisperMessageWordsLocally(const QStringList &words)
|
||||
{
|
||||
auto *app = getIApp();
|
||||
auto *app = getApp();
|
||||
|
||||
MessageBuilder b;
|
||||
|
||||
@@ -102,7 +102,7 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
|
||||
MessageElementFlag::Text, MessageColor::Text,
|
||||
FontStyle::ChatMediumBold);
|
||||
b.emplace<TextElement>("->", MessageElementFlag::Text,
|
||||
getIApp()->getThemes()->messages.textColors.system);
|
||||
getApp()->getThemes()->messages.textColors.system);
|
||||
b.emplace<TextElement>(words[1] + ":", MessageElementFlag::Text,
|
||||
MessageColor::Text, FontStyle::ChatMediumBold);
|
||||
|
||||
@@ -177,12 +177,12 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
|
||||
b->flags.set(MessageFlag::Whisper);
|
||||
auto messagexD = b.release();
|
||||
|
||||
getIApp()->getTwitch()->getWhispersChannel()->addMessage(
|
||||
getApp()->getTwitch()->getWhispersChannel()->addMessage(
|
||||
messagexD, MessageContext::Original);
|
||||
|
||||
if (getSettings()->inlineWhispers &&
|
||||
!(getSettings()->streamerModeSuppressInlineWhispers &&
|
||||
getIApp()->getStreamerMode()->isEnabled()))
|
||||
getApp()->getStreamerMode()->isEnabled()))
|
||||
{
|
||||
app->getTwitchAbstract()->forEachChannel(
|
||||
[&messagexD](ChannelPtr _channel) {
|
||||
@@ -210,7 +210,7 @@ QString sendWhisper(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
|
||||
@@ -22,7 +22,7 @@ QString toggleShieldMode(const CommandContext &ctx, bool isActivating)
|
||||
return {};
|
||||
}
|
||||
|
||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||
if (user->isAnon())
|
||||
|
||||
@@ -23,7 +23,7 @@ QString sendShoutout(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
channel->addSystemMessage("You must be logged in to send shoutout.");
|
||||
|
||||
@@ -98,7 +98,7 @@ QString startCommercial(const CommandContext &ctx)
|
||||
return "";
|
||||
}
|
||||
|
||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||
if (user->isAnon())
|
||||
|
||||
@@ -108,7 +108,7 @@ QString unbanUser(const CommandContext &ctx)
|
||||
|
||||
assert(!actions.value().empty());
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage(
|
||||
|
||||
@@ -25,7 +25,7 @@ QString updateUserColor(const CommandContext &ctx)
|
||||
"The /color command only works in Twitch channels.");
|
||||
return "";
|
||||
}
|
||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
// Avoid Helix calls without Client ID and/or OAuth Token
|
||||
if (user->isAnon())
|
||||
|
||||
@@ -104,7 +104,7 @@ QString sendWarn(const CommandContext &ctx)
|
||||
|
||||
assert(!actions.value().empty());
|
||||
|
||||
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto currentUser = getApp()->getAccounts()->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
ctx.channel->addSystemMessage("You must be logged in to warn someone!");
|
||||
|
||||
Reference in New Issue
Block a user