From 67c10fafc759ff72f420b2bb73fb1a5a082069af Mon Sep 17 00:00:00 2001 From: James Upjohn Date: Sun, 20 Mar 2022 00:02:29 +1300 Subject: [PATCH] chore: replace usages of obsolete twitch struct with backing field (#3614) Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> --- src/Application.cpp | 100 ++++++++---------- src/Application.hpp | 8 +- src/common/CompletionModel.cpp | 4 +- .../commands/CommandController.cpp | 18 ++-- .../filters/parser/FilterParser.cpp | 3 +- .../notifications/NotificationController.cpp | 4 +- src/providers/irc/IrcServer.cpp | 2 +- src/providers/twitch/IrcMessageHandler.cpp | 28 ++--- src/providers/twitch/TwitchChannel.cpp | 13 ++- src/providers/twitch/TwitchMessageBuilder.cpp | 4 +- src/singletons/NativeMessaging.cpp | 7 +- src/singletons/WindowManager.cpp | 10 +- src/util/StreamerMode.cpp | 2 +- src/widgets/FramelessEmbedWindow.cpp | 2 +- src/widgets/Window.cpp | 16 +-- src/widgets/dialogs/EmotePopup.cpp | 8 +- src/widgets/dialogs/SelectChannelDialog.cpp | 10 +- src/widgets/dialogs/UserInfoPopup.cpp | 2 +- src/widgets/dialogs/switcher/NewTabItem.cpp | 3 +- src/widgets/helper/ChannelView.cpp | 9 +- src/widgets/splits/InputCompletionPopup.cpp | 4 +- src/widgets/splits/Split.cpp | 3 +- src/widgets/splits/SplitInput.cpp | 2 +- 23 files changed, 120 insertions(+), 142 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 01306c58c..0d641c83f 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -61,7 +61,7 @@ Application::Application(Settings &_settings, Paths &_paths) , commands(&this->emplace()) , notifications(&this->emplace()) - , twitch2(&this->emplace()) + , twitch(&this->emplace()) , chatterinoBadges(&this->emplace()) , ffzBadges(&this->emplace()) , logging(&this->emplace()) @@ -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(chan.get())) - { - channel->addChannelPointReward(reward); - } - }); - } - else - { - qCDebug(chatterinoApp) - << "Couldn't find channel id of point reward"; - } - }); + postToThread([chan, reward] { + if (auto channel = + dynamic_cast(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()); }; diff --git a/src/Application.hpp b/src/Application.hpp index f05183f7b..5091322af 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -58,18 +58,12 @@ public: CommandController *const commands{}; NotificationController *const notifications{}; - TwitchIrcServer *const twitch2{}; + TwitchIrcServer *const twitch{}; ChatterinoBadges *const chatterinoBadges{}; FfzBadges *const ffzBadges{}; /*[[deprecated]]*/ Logging *const logging{}; - /// Provider-specific - struct { - /*[[deprecated("use twitch2 instead")]]*/ TwitchIrcServer *server{}; - /*[[deprecated("use twitch2->pubsub instead")]]*/ PubSub *pubsub{}; - } twitch; - private: void addSingleton(Singleton *singleton); void initPubsub(); diff --git a/src/common/CompletionModel.cpp b/src/common/CompletionModel.cpp index 5658e204c..c03fc830d 100644 --- a/src/common/CompletionModel.cpp +++ b/src/common/CompletionModel.cpp @@ -142,13 +142,13 @@ void CompletionModel::refresh(const QString &prefix, bool isFirstWord) } // Bttv Global - for (auto &emote : *getApp()->twitch2->getBttvEmotes().emotes()) + for (auto &emote : *getApp()->twitch->getBttvEmotes().emotes()) { addString(emote.first.string, TaggedString::Type::BTTVChannelEmote); } // Ffz Global - for (auto &emote : *getApp()->twitch2->getFfzEmotes().emotes()) + for (auto &emote : *getApp()->twitch->getFfzEmotes().emotes()) { addString(emote.first.string, TaggedString::Type::FFZChannelEmote); } diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 4a0625867..caa3c89f3 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -48,7 +48,7 @@ void sendWhisperMessage(const QString &text) // Constants used here are defined in TwitchChannel.hpp toSend.replace(ZERO_WIDTH_JOINER, ESCAPE_TAG); - app->twitch.server->sendMessage("jtv", toSend); + app->twitch->sendMessage("jtv", toSend); } bool appendWhisperMessageWordsLocally(const QStringList &words) @@ -68,8 +68,8 @@ bool appendWhisperMessageWordsLocally(const QStringList &words) const auto &acc = app->accounts->twitch.getCurrent(); const auto &accemotes = *acc->accessEmotes(); - const auto &bttvemotes = app->twitch.server->getBttvEmotes(); - const auto &ffzemotes = app->twitch.server->getFfzEmotes(); + const auto &bttvemotes = app->twitch->getBttvEmotes(); + const auto &ffzemotes = app->twitch->getFfzEmotes(); auto flags = MessageElementFlags(); auto emote = boost::optional{}; for (int i = 2; i < words.length(); i++) @@ -136,14 +136,14 @@ bool appendWhisperMessageWordsLocally(const QStringList &words) b->flags.set(MessageFlag::Whisper); auto messagexD = b.release(); - app->twitch.server->whispersChannel->addMessage(messagexD); + app->twitch->whispersChannel->addMessage(messagexD); auto overrideFlags = boost::optional(messagexD->flags); overrideFlags->set(MessageFlag::DoNotLog); if (getSettings()->inlineWhispers) { - app->twitch.server->forEachChannel( + app->twitch->forEachChannel( [&messagexD, overrideFlags](ChannelPtr _channel) { _channel->addMessage(messagexD, overrideFlags); }); @@ -501,7 +501,7 @@ void CommandController::initialize(Settings &, Paths &paths) stripChannelName(channelName); ChannelPtr channelTemp = - getApp()->twitch2->getChannelOrEmpty(channelName); + getApp()->twitch->getChannelOrEmpty(channelName); if (channelTemp->isEmpty()) { @@ -723,7 +723,7 @@ void CommandController::initialize(Settings &, Paths &paths) auto *split = new Split(static_cast( window.getNotebook().getOrAddSelectedPage())); - split->setChannel(app->twitch.server->getOrAddChannel(target)); + split->setChannel(app->twitch->getOrAddChannel(target)); window.getNotebook().getOrAddSelectedPage()->appendSplit(split); @@ -907,7 +907,7 @@ void CommandController::initialize(Settings &, Paths &paths) }); this->registerCommand("/raw", [](const QStringList &words, ChannelPtr) { - getApp()->twitch2->sendRawMessage(words.mid(1).join(" ")); + getApp()->twitch->sendRawMessage(words.mid(1).join(" ")); return ""; }); #ifndef NDEBUG @@ -922,7 +922,7 @@ void CommandController::initialize(Settings &, Paths &paths) return ""; } auto ircText = words.mid(1).join(" "); - getApp()->twitch2->addFakeMessage(ircText); + getApp()->twitch->addFakeMessage(ircText); return ""; }); #endif diff --git a/src/controllers/filters/parser/FilterParser.cpp b/src/controllers/filters/parser/FilterParser.cpp index 54918e33f..3e973da77 100644 --- a/src/controllers/filters/parser/FilterParser.cpp +++ b/src/controllers/filters/parser/FilterParser.cpp @@ -9,8 +9,7 @@ namespace filterparser { ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel) { - auto watchingChannel = - chatterino::getApp()->twitch.server->watchingChannel.get(); + auto watchingChannel = chatterino::getApp()->twitch->watchingChannel.get(); /* Known Identifiers * diff --git a/src/controllers/notifications/NotificationController.cpp b/src/controllers/notifications/NotificationController.cpp index 9f8bb88e1..10dba12ea 100644 --- a/src/controllers/notifications/NotificationController.cpp +++ b/src/controllers/notifications/NotificationController.cpp @@ -163,7 +163,7 @@ void NotificationController::fetchFakeChannels() for (std::vector::size_type i = 0; i != channelMap[Platform::Twitch].raw().size(); i++) { - auto chan = getApp()->twitch.server->getChannelOrEmpty( + auto chan = getApp()->twitch->getChannelOrEmpty( channelMap[Platform::Twitch].raw()[i]); if (chan->isEmpty()) { @@ -236,7 +236,7 @@ void NotificationController::checkStream(bool live, QString channelName) } MessageBuilder builder; TwitchMessageBuilder::liveMessage(channelName, &builder); - getApp()->twitch2->liveChannel->addMessage(builder.release()); + getApp()->twitch->liveChannel->addMessage(builder.release()); // Indicate that we have pushed notifications for this stream fakeTwitchChannels.push_back(channelName); diff --git a/src/providers/irc/IrcServer.cpp b/src/providers/irc/IrcServer.cpp index 0ccaa8f59..ded749d90 100644 --- a/src/providers/irc/IrcServer.cpp +++ b/src/providers/irc/IrcServer.cpp @@ -195,7 +195,7 @@ void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message) if (highlighted && showInMentions) { - getApp()->twitch2->mentionsChannel->addMessage(msg); + getApp()->twitch->mentionsChannel->addMessage(msg); } } else diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index 762885b31..e22f800f2 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -343,7 +343,7 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message) { return; } - auto chan = getApp()->twitch.server->getChannelOrEmpty(chanName); + auto chan = getApp()->twitch->getChannelOrEmpty(chanName); auto *twitchChannel = dynamic_cast(chan.get()); if (!twitchChannel) @@ -404,7 +404,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message) } // get channel - auto chan = getApp()->twitch.server->getChannelOrEmpty(chanName); + auto chan = getApp()->twitch->getChannelOrEmpty(chanName); if (chan->isEmpty()) { @@ -463,7 +463,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message) } // get channel - auto chan = getApp()->twitch.server->getChannelOrEmpty(chanName); + auto chan = getApp()->twitch->getChannelOrEmpty(chanName); if (chan->isEmpty()) { @@ -510,7 +510,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message) return; } - auto c = getApp()->twitch.server->getChannelOrEmpty(channelName); + auto c = getApp()->twitch->getChannelOrEmpty(channelName); if (c->isEmpty()) { return; @@ -565,7 +565,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message) args.isReceivedWhisper = true; - auto c = getApp()->twitch.server->whispersChannel.get(); + auto c = getApp()->twitch->whispersChannel.get(); TwitchMessageBuilder builder( c, message, args, @@ -581,11 +581,11 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message) MessagePtr _message = builder.build(); builder.triggerHighlights(); - getApp()->twitch.server->lastUserThatWhisperedMe.set(builder.userName); + getApp()->twitch->lastUserThatWhisperedMe.set(builder.userName); if (_message->flags.has(MessageFlag::Highlighted)) { - getApp()->twitch.server->mentionsChannel->addMessage(_message); + getApp()->twitch->mentionsChannel->addMessage(_message); } c->addMessage(_message); @@ -596,7 +596,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message) if (getSettings()->inlineWhispers) { - getApp()->twitch.server->forEachChannel( + getApp()->twitch->forEachChannel( [&_message, overrideFlags](ChannelPtr channel) { channel->addMessage(_message, overrideFlags); }); @@ -797,7 +797,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message) { // Notice wasn't targeted at a single channel, send to all twitch // channels - getApp()->twitch.server->forEachChannelAndSpecialChannels( + getApp()->twitch->forEachChannelAndSpecialChannels( [msg](const auto &c) { c->addMessage(msg); }); @@ -805,7 +805,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message) return; } - auto channel = getApp()->twitch.server->getChannelOrEmpty(channelName); + auto channel = getApp()->twitch->getChannelOrEmpty(channelName); if (channel->isEmpty()) { @@ -887,8 +887,8 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message) void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message) { - auto channel = getApp()->twitch.server->getChannelOrEmpty( - message->parameter(0).remove(0, 1)); + auto channel = + getApp()->twitch->getChannelOrEmpty(message->parameter(0).remove(0, 1)); auto *twitchChannel = dynamic_cast(channel.get()); if (!twitchChannel) @@ -906,8 +906,8 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message) void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message) { - auto channel = getApp()->twitch.server->getChannelOrEmpty( - message->parameter(0).remove(0, 1)); + auto channel = + getApp()->twitch->getChannelOrEmpty(message->parameter(0).remove(0, 1)); auto *twitchChannel = dynamic_cast(channel.get()); if (!twitchChannel) diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index b5ddac669..93b19fcb0 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -482,7 +482,7 @@ bool TwitchChannel::canReconnect() const void TwitchChannel::reconnect() { - getApp()->twitch.server->connect(); + getApp()->twitch->connect(); } QString TwitchChannel::roomId() const @@ -611,7 +611,7 @@ void TwitchChannel::setLive(bool newLiveStatus) MessageBuilder builder2; TwitchMessageBuilder::liveMessage(this->getDisplayName(), &builder2); - getApp()->twitch2->liveChannel->addMessage(builder2.release()); + getApp()->twitch->liveChannel->addMessage(builder2.release()); // Notify on all channels with a ping sound if (getSettings()->notificationOnAnyChannel && @@ -631,7 +631,7 @@ void TwitchChannel::setLive(bool newLiveStatus) // "delete" old 'CHANNEL is live' message LimitedQueueSnapshot snapshot = - getApp()->twitch2->liveChannel->getMessageSnapshot(); + getApp()->twitch->liveChannel->getMessageSnapshot(); int snapshotLength = snapshot.size(); // MSVC hates this code if the parens are not there @@ -877,10 +877,9 @@ void TwitchChannel::refreshPubsub() return; auto account = getApp()->accounts->twitch.getCurrent(); - getApp()->twitch2->pubsub->listenToChannelModerationActions(roomId, - account); - getApp()->twitch2->pubsub->listenToAutomod(roomId, account); - getApp()->twitch2->pubsub->listenToChannelPointRewards(roomId, account); + getApp()->twitch->pubsub->listenToChannelModerationActions(roomId, account); + getApp()->twitch->pubsub->listenToAutomod(roomId, account); + getApp()->twitch->pubsub->listenToChannelPointRewards(roomId, account); } void TwitchChannel::refreshChatters() diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 7de01ed77..bdfb199a7 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -972,8 +972,8 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name) { auto *app = getApp(); - const auto &globalBttvEmotes = app->twitch.server->getBttvEmotes(); - const auto &globalFfzEmotes = app->twitch.server->getFfzEmotes(); + const auto &globalBttvEmotes = app->twitch->getBttvEmotes(); + const auto &globalFfzEmotes = app->twitch->getFfzEmotes(); auto flags = MessageElementFlags(); auto emote = boost::optional{}; diff --git a/src/singletons/NativeMessaging.cpp b/src/singletons/NativeMessaging.cpp index d647fd0d9..f4dff7c0b 100644 --- a/src/singletons/NativeMessaging.cpp +++ b/src/singletons/NativeMessaging.cpp @@ -240,8 +240,8 @@ void NativeMessagingServer::ReceiverThread::handleMessage( postToThread([=] { if (!name.isEmpty()) { - app->twitch.server->watchingChannel.reset( - app->twitch.server->getOrAddChannel(name)); + app->twitch->watchingChannel.reset( + app->twitch->getOrAddChannel(name)); } if (attach || attachFullscreen) @@ -252,8 +252,7 @@ void NativeMessagingServer::ReceiverThread::handleMessage( AttachedWindow::get(::GetForegroundWindow(), args); if (!name.isEmpty()) { - window->setChannel( - app->twitch.server->getOrAddChannel(name)); + window->setChannel(app->twitch->getOrAddChannel(name)); } // } // window->show(); diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 83641c948..73fa9307c 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -605,23 +605,23 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor) if (descriptor.type_ == "twitch") { - return app->twitch.server->getOrAddChannel(descriptor.channelName_); + return app->twitch->getOrAddChannel(descriptor.channelName_); } else if (descriptor.type_ == "mentions") { - return app->twitch.server->mentionsChannel; + return app->twitch->mentionsChannel; } else if (descriptor.type_ == "watching") { - return app->twitch.server->watchingChannel; + return app->twitch->watchingChannel; } else if (descriptor.type_ == "whispers") { - return app->twitch.server->whispersChannel; + return app->twitch->whispersChannel; } else if (descriptor.type_ == "live") { - return app->twitch.server->liveChannel; + return app->twitch->liveChannel; } else if (descriptor.type_ == "irc") { diff --git a/src/util/StreamerMode.cpp b/src/util/StreamerMode.cpp index 059b6beaf..dfe8d85b6 100644 --- a/src/util/StreamerMode.cpp +++ b/src/util/StreamerMode.cpp @@ -76,7 +76,7 @@ bool isInStreamerMode() { shouldShowWarning = false; - getApp()->twitch2->addGlobalSystemMessage( + getApp()->twitch->addGlobalSystemMessage( "Streamer Mode is set to Automatic, but pgrep is missing. " "Install it to fix the issue or set Streamer Mode to " "Enabled or Disabled in the Settings."); diff --git a/src/widgets/FramelessEmbedWindow.cpp b/src/widgets/FramelessEmbedWindow.cpp index f34759f81..482f7c1f9 100644 --- a/src/widgets/FramelessEmbedWindow.cpp +++ b/src/widgets/FramelessEmbedWindow.cpp @@ -49,7 +49,7 @@ bool FramelessEmbedWindow::nativeEvent(const QByteArray &eventType, auto channelName = root.value("channel-name").toString(); this->split_->setChannel( - getApp()->twitch2->getOrAddChannel(channelName)); + getApp()->twitch->getOrAddChannel(channelName)); } } } diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index cc3dc71f2..b864709bf 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -254,7 +254,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions) static int index = 0; auto app = getApp(); const auto &msg = messages[index++ % messages.size()]; - app->twitch.server->addFakeMessage(msg); + app->twitch->addFakeMessage(msg); return ""; }); @@ -262,7 +262,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions) const auto &messages = cheerMessages; static int index = 0; const auto &msg = messages[index++ % messages.size()]; - getApp()->twitch.server->addFakeMessage(msg); + getApp()->twitch->addFakeMessage(msg); return ""; }); @@ -271,7 +271,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions) static int index = 0; auto app = getApp(); const auto &msg = messages[index++ % messages.size()]; - app->twitch.server->addFakeMessage(msg); + app->twitch->addFakeMessage(msg); return ""; }); @@ -282,15 +282,15 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions) if (alt) { doc.Parse(channelRewardMessage); - app->twitch.server->addFakeMessage(channelRewardIRCMessage); - app->twitch.pubsub->signals_.pointReward.redeemed.invoke( + app->twitch->addFakeMessage(channelRewardIRCMessage); + app->twitch->pubsub->signals_.pointReward.redeemed.invoke( doc["data"]["message"]["data"]["redemption"]); alt = !alt; } else { doc.Parse(channelRewardMessage2); - app->twitch.pubsub->signals_.pointReward.redeemed.invoke( + app->twitch->pubsub->signals_.pointReward.redeemed.invoke( doc["data"]["message"]["data"]["redemption"]); alt = !alt; } @@ -301,7 +301,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions) const auto &messages = emoteTestMessages; static int index = 0; const auto &msg = messages[index++ % messages.size()]; - getApp()->twitch.server->addFakeMessage(msg); + getApp()->twitch->addFakeMessage(msg); return ""; }); #endif @@ -466,7 +466,7 @@ void Window::addShortcuts() this->notebook_->select(splitContainer); Split *split = new Split(splitContainer); split->setChannel( - getApp()->twitch.server->getOrAddChannel(si.channelName)); + getApp()->twitch->getOrAddChannel(si.channelName)); split->setFilters(si.filters); splitContainer->appendSplit(split); return ""; diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index 90cfc7564..e45a99f55 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -341,9 +341,9 @@ void EmotePopup::loadChannel(ChannelPtr channel) *globalChannel, *subChannel, this->channel_->getName()); // global - addEmotes(*globalChannel, *getApp()->twitch2->getBttvEmotes().emotes(), + addEmotes(*globalChannel, *getApp()->twitch->getBttvEmotes().emotes(), "BetterTTV", MessageElementFlag::BttvEmote); - addEmotes(*globalChannel, *getApp()->twitch2->getFfzEmotes().emotes(), + addEmotes(*globalChannel, *getApp()->twitch->getFfzEmotes().emotes(), "FrankerFaceZ", MessageElementFlag::FfzEmote); // channel @@ -406,9 +406,9 @@ void EmotePopup::filterTwitchEmotes(std::shared_ptr searchChannel, } auto bttvGlobalEmotes = this->filterEmoteMap( - searchText, getApp()->twitch2->getBttvEmotes().emotes()); + searchText, getApp()->twitch->getBttvEmotes().emotes()); auto ffzGlobalEmotes = this->filterEmoteMap( - searchText, getApp()->twitch2->getFfzEmotes().emotes()); + searchText, getApp()->twitch->getFfzEmotes().emotes()); // twitch addEmoteSets(twitchGlobalEmotes, *searchChannel, *searchChannel, diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index 9eeb762d2..11f0b6488 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -350,24 +350,24 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const case TAB_TWITCH: { if (this->ui_.twitch.channel->isChecked()) { - return app->twitch.server->getOrAddChannel( + return app->twitch->getOrAddChannel( this->ui_.twitch.channelName->text().trimmed()); } else if (this->ui_.twitch.watching->isChecked()) { - return app->twitch.server->watchingChannel; + return app->twitch->watchingChannel; } else if (this->ui_.twitch.mentions->isChecked()) { - return app->twitch.server->mentionsChannel; + return app->twitch->mentionsChannel; } else if (this->ui_.twitch.whispers->isChecked()) { - return app->twitch.server->whispersChannel; + return app->twitch->whispersChannel; } else if (this->ui_.twitch.live->isChecked()) { - return app->twitch.server->liveChannel; + return app->twitch->liveChannel; } } break; diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index ecfc9ee2e..730617b09 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -301,7 +301,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent) auto split = window.getNotebook() .getOrAddSelectedPage() ->appendNewSplit(false); - split->setChannel(app->twitch2->getOrAddChannel( + split->setChannel(app->twitch->getOrAddChannel( loginName.toLower())); }); diff --git a/src/widgets/dialogs/switcher/NewTabItem.cpp b/src/widgets/dialogs/switcher/NewTabItem.cpp index 0713e5f7d..1dd55ff69 100644 --- a/src/widgets/dialogs/switcher/NewTabItem.cpp +++ b/src/widgets/dialogs/switcher/NewTabItem.cpp @@ -25,8 +25,7 @@ void NewTabItem::action() SplitContainer *container = nb.addPage(true); Split *split = new Split(container); - split->setChannel( - getApp()->twitch.server->getOrAddChannel(this->channelName_)); + split->setChannel(getApp()->twitch->getOrAddChannel(this->channelName_)); container->appendSplit(split); } diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 0ff30e598..b9b3bd8a1 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1016,15 +1016,15 @@ MessageElementFlags ChannelView::getFlags() const { flags.set(MessageElementFlag::ModeratorTools); } - if (this->underlyingChannel_ == app->twitch.server->mentionsChannel || - this->underlyingChannel_ == app->twitch.server->liveChannel) + if (this->underlyingChannel_ == app->twitch->mentionsChannel || + this->underlyingChannel_ == app->twitch->liveChannel) { flags.set(MessageElementFlag::ChannelName); flags.unset(MessageElementFlag::ChannelPointReward); } } - if (this->sourceChannel_ == app->twitch.server->mentionsChannel) + if (this->sourceChannel_ == app->twitch->mentionsChannel) flags.set(MessageElementFlag::ChannelName); return flags; @@ -1071,8 +1071,7 @@ void ChannelView::drawMessages(QPainter &painter) bool windowFocused = this->window() == QApplication::activeWindow(); auto app = getApp(); - bool isMentions = - this->underlyingChannel_ == app->twitch.server->mentionsChannel; + bool isMentions = this->underlyingChannel_ == app->twitch->mentionsChannel; for (size_t i = start; i < messagesSnapshot.size(); ++i) { diff --git a/src/widgets/splits/InputCompletionPopup.cpp b/src/widgets/splits/InputCompletionPopup.cpp index 1badc8949..1cf8fee5e 100644 --- a/src/widgets/splits/InputCompletionPopup.cpp +++ b/src/widgets/splits/InputCompletionPopup.cpp @@ -106,9 +106,9 @@ void InputCompletionPopup::updateEmotes(const QString &text, ChannelPtr channel) addEmotes(emotes, *ffz, text, "Channel FrankerFaceZ"); } - if (auto bttvG = getApp()->twitch2->getBttvEmotes().emotes()) + if (auto bttvG = getApp()->twitch->getBttvEmotes().emotes()) addEmotes(emotes, *bttvG, text, "Global BetterTTV"); - if (auto ffzG = getApp()->twitch2->getFfzEmotes().emotes()) + if (auto ffzG = getApp()->twitch->getFfzEmotes().emotes()) addEmotes(emotes, *ffzG, text, "Global FrankerFaceZ"); addEmojis(emotes, getApp()->emotes->emojis.emojis, text); diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 937bfc111..5b6b1ff41 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -125,8 +125,7 @@ Split::Split(QWidget *parent) this->view_->openChannelIn.connect([this]( QString twitchChannel, FromTwitchLinkOpenChannelIn openIn) { - ChannelPtr channel = - getApp()->twitch.server->getOrAddChannel(twitchChannel); + ChannelPtr channel = getApp()->twitch->getOrAddChannel(twitchChannel); switch (openIn) { case FromTwitchLinkOpenChannelIn::Split: diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 3c73aa7e2..437c56e98 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -687,7 +687,7 @@ void SplitInput::editTextChanged() if (text.startsWith("/r ", Qt::CaseInsensitive) && this->split_->getChannel()->isTwitchChannel()) { - QString lastUser = app->twitch.server->lastUserThatWhisperedMe.get(); + QString lastUser = app->twitch->lastUserThatWhisperedMe.get(); if (!lastUser.isEmpty()) { this->ui_.textEdit->setPlainText("/w " + lastUser + text.mid(2));