fix: remove deprecated Application::getTwitchAbstract (#5560)

This commit is contained in:
pajlada
2024-08-25 13:38:57 +02:00
committed by GitHub
parent 3e510fd9e9
commit ac88730563
21 changed files with 45 additions and 69 deletions
+1
View File
@@ -70,6 +70,7 @@
- Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532) - Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532)
- Dev: Refactored code that's responsible for deleting old update files. (#5535) - Dev: Refactored code that's responsible for deleting old update files. (#5535)
- Dev: Cleanly exit on shutdown. (#5537) - Dev: Cleanly exit on shutdown. (#5537)
- Dev: Removed the `getTwitchAbstract` method in `Application`. (#5560)
- Dev: Renamed threads created by Chatterino on Linux and Windows. (#5538, #5539, #5544) - Dev: Renamed threads created by Chatterino on Linux and Windows. (#5538, #5539, #5544)
- Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527) - Dev: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
- Dev: Added `FlagsEnum::isEmpty`. (#5550) - Dev: Added `FlagsEnum::isEmpty`. (#5550)
-7
View File
@@ -133,13 +133,6 @@ public:
return nullptr; return nullptr;
} }
ITwitchIrcServer *getTwitchAbstract() override
{
assert(false && "EmptyApplication::getTwitchAbstract was called "
"without being initialized");
return nullptr;
}
PubSub *getTwitchPubSub() override PubSub *getTwitchPubSub() override
{ {
assert(false && "getTwitchPubSub was called without being initialized"); assert(false && "getTwitchPubSub was called without being initialized");
-7
View File
@@ -512,13 +512,6 @@ ITwitchIrcServer *Application::getTwitch()
return this->twitch.get(); return this->twitch.get();
} }
ITwitchIrcServer *Application::getTwitchAbstract()
{
assertInGuiThread();
return this->twitch.get();
}
PubSub *Application::getTwitchPubSub() PubSub *Application::getTwitchPubSub()
{ {
assertInGuiThread(); assertInGuiThread();
-3
View File
@@ -83,7 +83,6 @@ public:
virtual HighlightController *getHighlights() = 0; virtual HighlightController *getHighlights() = 0;
virtual NotificationController *getNotifications() = 0; virtual NotificationController *getNotifications() = 0;
virtual ITwitchIrcServer *getTwitch() = 0; virtual ITwitchIrcServer *getTwitch() = 0;
virtual ITwitchIrcServer *getTwitchAbstract() = 0;
virtual PubSub *getTwitchPubSub() = 0; virtual PubSub *getTwitchPubSub() = 0;
virtual ILogging *getChatLogger() = 0; virtual ILogging *getChatLogger() = 0;
virtual IChatterinoBadges *getChatterinoBadges() = 0; virtual IChatterinoBadges *getChatterinoBadges() = 0;
@@ -194,8 +193,6 @@ public:
NotificationController *getNotifications() override; NotificationController *getNotifications() override;
HighlightController *getHighlights() override; HighlightController *getHighlights() override;
ITwitchIrcServer *getTwitch() override; ITwitchIrcServer *getTwitch() override;
[[deprecated("use getTwitch()")]] ITwitchIrcServer *getTwitchAbstract()
override;
PubSub *getTwitchPubSub() override; PubSub *getTwitchPubSub() override;
ILogging *getChatLogger() override; ILogging *getChatLogger() override;
FfzBadges *getFfzBadges() override; FfzBadges *getFfzBadges() override;
+4 -5
View File
@@ -388,7 +388,7 @@ QString popup(const CommandContext &ctx)
} }
// Open channel passed as argument in a popup // Open channel passed as argument in a popup
auto targetChannel = getApp()->getTwitchAbstract()->getOrAddChannel(target); auto targetChannel = getApp()->getTwitch()->getOrAddChannel(target);
getApp()->getWindows()->openInPopup(targetChannel); getApp()->getWindows()->openInPopup(targetChannel);
return ""; return "";
@@ -530,8 +530,7 @@ QString sendRawMessage(const CommandContext &ctx)
if (ctx.channel->isTwitchChannel()) if (ctx.channel->isTwitchChannel())
{ {
getApp()->getTwitchAbstract()->sendRawMessage( getApp()->getTwitch()->sendRawMessage(ctx.words.mid(1).join(" "));
ctx.words.mid(1).join(" "));
} }
else else
{ {
@@ -564,7 +563,7 @@ QString injectFakeMessage(const CommandContext &ctx)
} }
auto ircText = ctx.words.mid(1).join(" "); auto ircText = ctx.words.mid(1).join(" ");
getApp()->getTwitchAbstract()->addFakeMessage(ircText); getApp()->getTwitch()->addFakeMessage(ircText);
return ""; return "";
} }
@@ -663,7 +662,7 @@ QString openUsercard(const CommandContext &ctx)
stripChannelName(channelName); stripChannelName(channelName);
ChannelPtr channelTemp = ChannelPtr channelTemp =
getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName); getApp()->getTwitch()->getChannelOrEmpty(channelName);
if (channelTemp->isEmpty()) if (channelTemp->isEmpty())
{ {
@@ -182,10 +182,9 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
!(getSettings()->streamerModeSuppressInlineWhispers && !(getSettings()->streamerModeSuppressInlineWhispers &&
getApp()->getStreamerMode()->isEnabled())) getApp()->getStreamerMode()->isEnabled()))
{ {
app->getTwitchAbstract()->forEachChannel( app->getTwitch()->forEachChannel([&messagexD](ChannelPtr _channel) {
[&messagexD](ChannelPtr _channel) { _channel->addMessage(messagexD, MessageContext::Repost);
_channel->addMessage(messagexD, MessageContext::Repost); });
});
} }
return true; return true;
@@ -179,7 +179,7 @@ void NotificationController::fetchFakeChannels()
for (size_t i = 0; i < channelMap[Platform::Twitch].raw().size(); i++) for (size_t i = 0; i < channelMap[Platform::Twitch].raw().size(); i++)
{ {
const auto &name = channelMap[Platform::Twitch].raw()[i]; const auto &name = channelMap[Platform::Twitch].raw()[i];
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(name); auto chan = getApp()->getTwitch()->getChannelOrEmpty(name);
if (chan->isEmpty()) if (chan->isEmpty())
{ {
channels.push_back(name); channels.push_back(name);
+1 -1
View File
@@ -300,7 +300,7 @@ int ChannelRef::get_by_name(lua_State *L)
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
} }
auto chn = getApp()->getTwitchAbstract()->getChannelOrEmpty(name); auto chn = getApp()->getTwitch()->getChannelOrEmpty(name);
lua::push(L, chn); lua::push(L, chn);
return 1; return 1;
} }
+9 -10
View File
@@ -732,7 +732,7 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
{ {
return; return;
} }
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName); auto chan = getApp()->getTwitch()->getChannelOrEmpty(chanName);
auto *twitchChannel = dynamic_cast<TwitchChannel *>(chan.get()); auto *twitchChannel = dynamic_cast<TwitchChannel *>(chan.get());
if (!twitchChannel) if (!twitchChannel)
@@ -794,7 +794,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
} }
// get channel // get channel
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName); auto chan = getApp()->getTwitch()->getChannelOrEmpty(chanName);
if (chan->isEmpty()) if (chan->isEmpty())
{ {
@@ -839,7 +839,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
} }
// get channel // get channel
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName); auto chan = getApp()->getTwitch()->getChannelOrEmpty(chanName);
if (chan->isEmpty()) if (chan->isEmpty())
{ {
@@ -887,7 +887,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
return; return;
} }
auto c = getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName); auto c = getApp()->getTwitch()->getChannelOrEmpty(channelName);
if (c->isEmpty()) if (c->isEmpty())
{ {
return; return;
@@ -976,8 +976,8 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
!(getSettings()->streamerModeSuppressInlineWhispers && !(getSettings()->streamerModeSuppressInlineWhispers &&
getApp()->getStreamerMode()->isEnabled())) getApp()->getStreamerMode()->isEnabled()))
{ {
getApp()->getTwitchAbstract()->forEachChannel([&message, overrideFlags]( getApp()->getTwitch()->forEachChannel([&message, overrideFlags](
ChannelPtr channel) { ChannelPtr channel) {
channel->addMessage(message, MessageContext::Repost, overrideFlags); channel->addMessage(message, MessageContext::Repost, overrideFlags);
}); });
} }
@@ -1119,8 +1119,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
return; return;
} }
auto channel = auto channel = getApp()->getTwitch()->getChannelOrEmpty(channelName);
getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
if (channel->isEmpty()) if (channel->isEmpty())
{ {
@@ -1202,7 +1201,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message) void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
{ {
auto channel = getApp()->getTwitchAbstract()->getChannelOrEmpty( auto channel = getApp()->getTwitch()->getChannelOrEmpty(
message->parameter(0).remove(0, 1)); message->parameter(0).remove(0, 1));
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()); auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
@@ -1225,7 +1224,7 @@ void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message) void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
{ {
auto channel = getApp()->getTwitchAbstract()->getChannelOrEmpty( auto channel = getApp()->getTwitch()->getChannelOrEmpty(
message->parameter(0).remove(0, 1)); message->parameter(0).remove(0, 1));
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()); auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
+1 -1
View File
@@ -725,7 +725,7 @@ bool TwitchChannel::canReconnect() const
void TwitchChannel::reconnect() void TwitchChannel::reconnect()
{ {
getApp()->getTwitchAbstract()->connect(); getApp()->getTwitch()->connect();
} }
QString TwitchChannel::getCurrentStreamID() const QString TwitchChannel::getCurrentStreamID() const
+3 -4
View File
@@ -254,7 +254,7 @@ void NativeMessagingServer::ReceiverThread::handleSelect(
postToThread([=] { postToThread([=] {
if (!name.isEmpty()) if (!name.isEmpty())
{ {
auto channel = getApp()->getTwitchAbstract()->getOrAddChannel(name); auto channel = getApp()->getTwitch()->getOrAddChannel(name);
if (getApp()->getTwitch()->getWatchingChannel().get() != channel) if (getApp()->getTwitch()->getWatchingChannel().get() != channel)
{ {
getApp()->getTwitch()->setWatchingChannel(channel); getApp()->getTwitch()->setWatchingChannel(channel);
@@ -268,7 +268,7 @@ void NativeMessagingServer::ReceiverThread::handleSelect(
if (!name.isEmpty()) if (!name.isEmpty())
{ {
window->setChannel( window->setChannel(
getApp()->getTwitchAbstract()->getOrAddChannel(name)); getApp()->getTwitch()->getOrAddChannel(name));
} }
#endif #endif
} }
@@ -319,8 +319,7 @@ void NativeMessagingServer::syncChannels(const QJsonArray &twitchChannels)
continue; continue;
} }
// the deduping is done on the extension side // the deduping is done on the extension side
updated.emplace_back( updated.emplace_back(getApp()->getTwitch()->getOrAddChannel(name));
getApp()->getTwitchAbstract()->getOrAddChannel(name));
} }
// This will destroy channels that aren't used anymore. // This will destroy channels that aren't used anymore.
+2 -2
View File
@@ -74,7 +74,7 @@ bool isBroadcasterSoftwareActive()
shouldShowTimeoutWarning = false; shouldShowTimeoutWarning = false;
postToThread([] { postToThread([] {
getApp()->getTwitchAbstract()->addGlobalSystemMessage( getApp()->getTwitch()->addGlobalSystemMessage(
"Streamer Mode is set to Automatic, but pgrep timed " "Streamer Mode is set to Automatic, but pgrep timed "
"out. This can happen if your system lagged at the " "out. This can happen if your system lagged at the "
"wrong moment. If Streamer Mode continues to not work, " "wrong moment. If Streamer Mode continues to not work, "
@@ -94,7 +94,7 @@ bool isBroadcasterSoftwareActive()
shouldShowWarning = false; shouldShowWarning = false;
postToThread([] { postToThread([] {
getApp()->getTwitchAbstract()->addGlobalSystemMessage( getApp()->getTwitch()->addGlobalSystemMessage(
"Streamer Mode is set to Automatic, but pgrep is " "Streamer Mode is set to Automatic, but pgrep is "
"missing. " "missing. "
"Install it to fix the issue or set Streamer Mode to " "Install it to fix the issue or set Streamer Mode to "
+2 -3
View File
@@ -668,8 +668,7 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
if (descriptor.type_ == "twitch") if (descriptor.type_ == "twitch")
{ {
return getApp()->getTwitchAbstract()->getOrAddChannel( return getApp()->getTwitch()->getOrAddChannel(descriptor.channelName_);
descriptor.channelName_);
} }
else if (descriptor.type_ == "mentions") else if (descriptor.type_ == "mentions")
{ {
@@ -693,7 +692,7 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
} }
else if (descriptor.type_ == "misc") else if (descriptor.type_ == "misc")
{ {
return getApp()->getTwitchAbstract()->getChannelOrEmpty( return getApp()->getTwitch()->getChannelOrEmpty(
descriptor.channelName_); descriptor.channelName_);
} }
+1 -2
View File
@@ -54,8 +54,7 @@ bool FramelessEmbedWindow::nativeEvent(const QByteArray &eventType,
auto channelName = root.value("channel-name").toString(); auto channelName = root.value("channel-name").toString();
this->split_->setChannel( this->split_->setChannel(
getApp()->getTwitchAbstract()->getOrAddChannel( getApp()->getTwitch()->getOrAddChannel(channelName));
channelName));
} }
} }
} }
+8 -8
View File
@@ -261,7 +261,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
const auto &messages = getSampleMiscMessages(); const auto &messages = getSampleMiscMessages();
static int index = 0; static int index = 0;
const auto &msg = messages[index++ % messages.size()]; const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg); getApp()->getTwitch()->addFakeMessage(msg);
return ""; return "";
}); });
@@ -269,7 +269,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
const auto &messages = getSampleCheerMessages(); const auto &messages = getSampleCheerMessages();
static int index = 0; static int index = 0;
const auto &msg = messages[index++ % messages.size()]; const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg); getApp()->getTwitch()->addFakeMessage(msg);
return ""; return "";
}); });
@@ -277,7 +277,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
const auto &messages = getSampleLinkMessages(); const auto &messages = getSampleLinkMessages();
static int index = 0; static int index = 0;
const auto &msg = messages[index++ % messages.size()]; const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg); getApp()->getTwitch()->addFakeMessage(msg);
return ""; return "";
}); });
@@ -292,7 +292,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
oMessage->toInner<PubSubMessageMessage>() oMessage->toInner<PubSubMessageMessage>()
->toInner<PubSubCommunityPointsChannelV1Message>(); ->toInner<PubSubCommunityPointsChannelV1Message>();
getApp()->getTwitchAbstract()->addFakeMessage( getApp()->getTwitch()->addFakeMessage(
getSampleChannelRewardIRCMessage()); getSampleChannelRewardIRCMessage());
getApp()->getTwitchPubSub()->pointReward.redeemed.invoke( getApp()->getTwitchPubSub()->pointReward.redeemed.invoke(
oInnerMessage->data.value("redemption").toObject()); oInnerMessage->data.value("redemption").toObject());
@@ -316,7 +316,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
const auto &messages = getSampleEmoteTestMessages(); const auto &messages = getSampleEmoteTestMessages();
static int index = 0; static int index = 0;
const auto &msg = messages[index++ % messages.size()]; const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg); getApp()->getTwitch()->addFakeMessage(msg);
return ""; return "";
}); });
@@ -324,7 +324,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
const auto &messages = getSampleSubMessages(); const auto &messages = getSampleSubMessages();
static int index = 0; static int index = 0;
const auto &msg = messages[index++ % messages.size()]; const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg); getApp()->getTwitch()->addFakeMessage(msg);
return ""; return "";
}); });
#endif #endif
@@ -487,8 +487,8 @@ void Window::addShortcuts()
splitContainer = this->notebook_->getOrAddSelectedPage(); splitContainer = this->notebook_->getOrAddSelectedPage();
} }
Split *split = new Split(splitContainer); Split *split = new Split(splitContainer);
split->setChannel(getApp()->getTwitchAbstract()->getOrAddChannel( split->setChannel(
si.channelName)); getApp()->getTwitch()->getOrAddChannel(si.channelName));
split->setFilters(si.filters); split->setFilters(si.filters);
splitContainer->insertSplit(split); splitContainer->insertSplit(split);
splitContainer->setSelected(split); splitContainer->setSelected(split);
+1 -1
View File
@@ -262,7 +262,7 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
case TAB_TWITCH: { case TAB_TWITCH: {
if (this->ui_.twitch.channel->isChecked()) if (this->ui_.twitch.channel->isChecked())
{ {
return getApp()->getTwitchAbstract()->getOrAddChannel( return getApp()->getTwitch()->getOrAddChannel(
this->ui_.twitch.channelName->text().trimmed()); this->ui_.twitch.channelName->text().trimmed());
} }
else if (this->ui_.twitch.watching->isChecked()) else if (this->ui_.twitch.watching->isChecked())
+3 -4
View File
@@ -305,16 +305,15 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
.getOrAddSelectedPage() .getOrAddSelectedPage()
->appendNewSplit(false); ->appendNewSplit(false);
split->setChannel( split->setChannel(
app->getTwitchAbstract()->getOrAddChannel( app->getTwitch()->getOrAddChannel(
loginName.toLower())); loginName.toLower()));
}); });
menu->addAction( menu->addAction(
"Open channel in a new tab", this, [loginName] { "Open channel in a new tab", this, [loginName] {
ChannelPtr channel = ChannelPtr channel =
getApp() getApp()->getTwitch()->getOrAddChannel(
->getTwitchAbstract() loginName);
->getOrAddChannel(loginName);
auto &nb = getApp() auto &nb = getApp()
->getWindows() ->getWindows()
->getMainWindow() ->getMainWindow()
@@ -21,8 +21,7 @@ NewPopupItem::NewPopupItem(const QString &channelName)
void NewPopupItem::action() void NewPopupItem::action()
{ {
auto channel = auto channel = getApp()->getTwitch()->getOrAddChannel(this->channelName_);
getApp()->getTwitchAbstract()->getOrAddChannel(this->channelName_);
getApp()->getWindows()->openInPopup(channel); getApp()->getWindows()->openInPopup(channel);
} }
+1 -1
View File
@@ -27,7 +27,7 @@ void NewTabItem::action()
Split *split = new Split(container); Split *split = new Split(container);
split->setChannel( split->setChannel(
getApp()->getTwitchAbstract()->getOrAddChannel(this->channelName_)); getApp()->getTwitch()->getOrAddChannel(this->channelName_));
container->insertSplit(split); container->insertSplit(split);
} }
+2 -2
View File
@@ -2763,8 +2763,8 @@ void ChannelView::showUserInfoPopup(const QString &userName,
auto *userPopup = auto *userPopup =
new UserInfoPopup(getSettings()->autoCloseUserPopup, this->split_); new UserInfoPopup(getSettings()->autoCloseUserPopup, this->split_);
auto contextChannel = getApp()->getTwitchAbstract()->getChannelOrEmpty( auto contextChannel =
alternativePopoutChannel); getApp()->getTwitch()->getChannelOrEmpty(alternativePopoutChannel);
auto openingChannel = this->hasSourceChannel() ? this->sourceChannel_ auto openingChannel = this->hasSourceChannel() ? this->sourceChannel_
: this->underlyingChannel_; : this->underlyingChannel_;
userPopup->setData(userName, contextChannel, openingChannel); userPopup->setData(userName, contextChannel, openingChannel);
+1 -1
View File
@@ -271,7 +271,7 @@ Split::Split(QWidget *parent)
std::ignore = this->view_->openChannelIn.connect( std::ignore = this->view_->openChannelIn.connect(
[this](QString twitchChannel, FromTwitchLinkOpenChannelIn openIn) { [this](QString twitchChannel, FromTwitchLinkOpenChannelIn openIn) {
ChannelPtr channel = ChannelPtr channel =
getApp()->getTwitchAbstract()->getOrAddChannel(twitchChannel); getApp()->getTwitch()->getOrAddChannel(twitchChannel);
switch (openIn) switch (openIn)
{ {
case FromTwitchLinkOpenChannelIn::Split: case FromTwitchLinkOpenChannelIn::Split: