chore: remove Singleton & replace getIApp with getApp (#5514)

This commit is contained in:
pajlada
2024-07-21 15:09:59 +02:00
committed by GitHub
parent 21186df058
commit 5deec1f02f
145 changed files with 802 additions and 856 deletions
@@ -121,7 +121,7 @@ const std::unordered_map<QString, VariableReplacer> COMMAND_VARS{
(void)(channel); //unused
(void)(message); //unused
auto uid =
getIApp()->getAccounts()->twitch.getCurrent()->getUserId();
getApp()->getAccounts()->twitch.getCurrent()->getUserId();
return uid.isEmpty() ? altText : uid;
},
},
@@ -131,7 +131,7 @@ const std::unordered_map<QString, VariableReplacer> COMMAND_VARS{
(void)(channel); //unused
(void)(message); //unused
auto name =
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
return name.isEmpty() ? altText : name;
},
},
@@ -263,7 +263,7 @@ const std::unordered_map<QString, VariableReplacer> COMMAND_VARS{
namespace chatterino {
void CommandController::initialize(Settings &, const Paths &paths)
CommandController::CommandController(const Paths &paths)
{
// Update commands map when the vector of commands has been updated
auto addFirstMatchToMap = [this](auto args) {
@@ -485,7 +485,7 @@ QString CommandController::execCommand(const QString &textNoEmoji,
ChannelPtr channel, bool dryRun)
{
QString text =
getIApp()->getEmotes()->getEmojis()->replaceShortCodes(textNoEmoji);
getApp()->getEmotes()->getEmojis()->replaceShortCodes(textNoEmoji);
QStringList words = text.split(' ', Qt::SkipEmptyParts);
if (words.length() == 0)
@@ -500,7 +500,7 @@ QString CommandController::execCommand(const QString &textNoEmoji,
const auto it = this->userCommands_.find(commandName);
if (it != this->userCommands_.end())
{
text = getIApp()->getEmotes()->getEmojis()->replaceShortCodes(
text = getApp()->getEmotes()->getEmojis()->replaceShortCodes(
this->execCustomCommand(words, it.value(), dryRun, channel));
words = text.split(' ', Qt::SkipEmptyParts);
@@ -570,7 +570,7 @@ bool CommandController::registerPluginCommand(const QString &commandName)
}
this->commands_[commandName] = [commandName](const CommandContext &ctx) {
return getIApp()->getPlugins()->tryExecPluginCommand(commandName, ctx);
return getApp()->getPlugins()->tryExecPluginCommand(commandName, ctx);
};
this->pluginCommands_.append(commandName);
return true;