chore: replace usages of obsolete twitch struct with backing field (#3614)

Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
This commit is contained in:
James Upjohn
2022-03-20 00:02:29 +13:00
committed by GitHub
parent 4c275cb183
commit 67c10fafc7
23 changed files with 120 additions and 142 deletions
+45 -55
View File
@@ -61,7 +61,7 @@ Application::Application(Settings &_settings, Paths &_paths)
, commands(&this->emplace<CommandController>())
, notifications(&this->emplace<NotificationController>())
, twitch2(&this->emplace<TwitchIrcServer>())
, twitch(&this->emplace<TwitchIrcServer>())
, chatterinoBadges(&this->emplace<ChatterinoBadges>())
, ffzBadges(&this->emplace<FfzBadges>())
, logging(&this->emplace<Logging>())
@@ -71,9 +71,6 @@ Application::Application(Settings &_settings, Paths &_paths)
this->fonts->fontChanged.connect([this]() {
this->windows->layoutChannelViews();
});
this->twitch.server = this->twitch2;
this->twitch.pubsub = this->twitch2->pubsub;
}
void Application::initialize(Settings &settings, Paths &paths)
@@ -147,7 +144,7 @@ int Application::run(QApplication &qtApp)
{
assert(isAppInitialized);
this->twitch.server->connect();
this->twitch->connect();
if (!getArgs().isFramelessEmbed)
{
@@ -199,10 +196,9 @@ void Application::initNm(Paths &paths)
void Application::initPubsub()
{
this->twitch.pubsub->signals_.moderation.chatCleared.connect(
this->twitch->pubsub->signals_.moderation.chatCleared.connect(
[this](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
return;
@@ -217,10 +213,9 @@ void Application::initPubsub()
});
});
this->twitch.pubsub->signals_.moderation.modeChanged.connect(
this->twitch->pubsub->signals_.moderation.modeChanged.connect(
[this](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
return;
@@ -244,10 +239,9 @@ void Application::initPubsub()
});
});
this->twitch.pubsub->signals_.moderation.moderationStateChanged.connect(
this->twitch->pubsub->signals_.moderation.moderationStateChanged.connect(
[this](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
return;
@@ -266,10 +260,9 @@ void Application::initPubsub()
});
});
this->twitch.pubsub->signals_.moderation.userBanned.connect(
this->twitch->pubsub->signals_.moderation.userBanned.connect(
[&](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
@@ -283,10 +276,9 @@ void Application::initPubsub()
chan->addOrReplaceTimeout(msg);
});
});
this->twitch.pubsub->signals_.moderation.messageDeleted.connect(
this->twitch->pubsub->signals_.moderation.messageDeleted.connect(
[&](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty() || getSettings()->hideDeletionActions)
{
@@ -324,10 +316,9 @@ void Application::initPubsub()
});
});
this->twitch.pubsub->signals_.moderation.userUnbanned.connect(
this->twitch->pubsub->signals_.moderation.userUnbanned.connect(
[&](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
@@ -341,10 +332,9 @@ void Application::initPubsub()
});
});
this->twitch.pubsub->signals_.moderation.automodMessage.connect(
this->twitch->pubsub->signals_.moderation.automodMessage.connect(
[&](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
@@ -358,10 +348,9 @@ void Application::initPubsub()
});
});
this->twitch.pubsub->signals_.moderation.automodUserMessage.connect(
this->twitch->pubsub->signals_.moderation.automodUserMessage.connect(
[&](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
@@ -376,10 +365,9 @@ void Application::initPubsub()
chan->deleteMessage(msg->id);
});
this->twitch.pubsub->signals_.moderation.automodInfoMessage.connect(
this->twitch->pubsub->signals_.moderation.automodInfoMessage.connect(
[&](const auto &action) {
auto chan =
this->twitch.server->getChannelOrEmptyByID(action.roomID);
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
if (chan->isEmpty())
{
@@ -392,36 +380,38 @@ void Application::initPubsub()
});
});
this->twitch.pubsub->signals_.pointReward.redeemed.connect([&](auto &data) {
QString channelId;
if (rj::getSafe(data, "channel_id", channelId))
{
auto chan = this->twitch.server->getChannelOrEmptyByID(channelId);
this->twitch->pubsub->signals_.pointReward.redeemed.connect(
[&](auto &data) {
QString channelId;
if (rj::getSafe(data, "channel_id", channelId))
{
auto chan = this->twitch->getChannelOrEmptyByID(channelId);
auto reward = ChannelPointReward(data);
auto reward = ChannelPointReward(data);
postToThread([chan, reward] {
if (auto channel = dynamic_cast<TwitchChannel *>(chan.get()))
{
channel->addChannelPointReward(reward);
}
});
}
else
{
qCDebug(chatterinoApp)
<< "Couldn't find channel id of point reward";
}
});
postToThread([chan, reward] {
if (auto channel =
dynamic_cast<TwitchChannel *>(chan.get()))
{
channel->addChannelPointReward(reward);
}
});
}
else
{
qCDebug(chatterinoApp)
<< "Couldn't find channel id of point reward";
}
});
this->twitch.pubsub->start();
this->twitch->pubsub->start();
auto RequestModerationActions = [=]() {
this->twitch.server->pubsub->unlistenAllModerationActions();
this->twitch->pubsub->unlistenAllModerationActions();
// TODO(pajlada): Unlisten to all authed topics instead of only
// moderation topics this->twitch.pubsub->UnlistenAllAuthedTopics();
// moderation topics this->twitch->pubsub->UnlistenAllAuthedTopics();
this->twitch.server->pubsub->listenToWhispers(
this->twitch->pubsub->listenToWhispers(
this->accounts->twitch.getCurrent());
};