Skip to content

Commit

Permalink
fix: remove deprecated Application::getTwitchAbstract (#5560)
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada authored Aug 25, 2024
1 parent 3e510fd commit ac88730
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 69 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
- Dev: Refactored 7TV/BTTV definitions out of `TwitchIrcServer` into `Application`. (#5532)
- Dev: Refactored code that's responsible for deleting old update files. (#5535)
- 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: Refactored a few `#define`s into `const(expr)` and cleaned includes. (#5527)
- Dev: Added `FlagsEnum::isEmpty`. (#5550)
Expand Down
7 changes: 0 additions & 7 deletions mocks/include/mocks/EmptyApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,6 @@ class EmptyApplication : public IApplication
return nullptr;
}

ITwitchIrcServer *getTwitchAbstract() override
{
assert(false && "EmptyApplication::getTwitchAbstract was called "
"without being initialized");
return nullptr;
}

PubSub *getTwitchPubSub() override
{
assert(false && "getTwitchPubSub was called without being initialized");
Expand Down
7 changes: 0 additions & 7 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,6 @@ ITwitchIrcServer *Application::getTwitch()
return this->twitch.get();
}

ITwitchIrcServer *Application::getTwitchAbstract()
{
assertInGuiThread();

return this->twitch.get();
}

PubSub *Application::getTwitchPubSub()
{
assertInGuiThread();
Expand Down
3 changes: 0 additions & 3 deletions src/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class IApplication
virtual HighlightController *getHighlights() = 0;
virtual NotificationController *getNotifications() = 0;
virtual ITwitchIrcServer *getTwitch() = 0;
virtual ITwitchIrcServer *getTwitchAbstract() = 0;
virtual PubSub *getTwitchPubSub() = 0;
virtual ILogging *getChatLogger() = 0;
virtual IChatterinoBadges *getChatterinoBadges() = 0;
Expand Down Expand Up @@ -194,8 +193,6 @@ class Application : public IApplication
NotificationController *getNotifications() override;
HighlightController *getHighlights() override;
ITwitchIrcServer *getTwitch() override;
[[deprecated("use getTwitch()")]] ITwitchIrcServer *getTwitchAbstract()
override;
PubSub *getTwitchPubSub() override;
ILogging *getChatLogger() override;
FfzBadges *getFfzBadges() override;
Expand Down
9 changes: 4 additions & 5 deletions src/controllers/commands/builtin/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ QString popup(const CommandContext &ctx)
}

// Open channel passed as argument in a popup
auto targetChannel = getApp()->getTwitchAbstract()->getOrAddChannel(target);
auto targetChannel = getApp()->getTwitch()->getOrAddChannel(target);
getApp()->getWindows()->openInPopup(targetChannel);

return "";
Expand Down Expand Up @@ -530,8 +530,7 @@ QString sendRawMessage(const CommandContext &ctx)

if (ctx.channel->isTwitchChannel())
{
getApp()->getTwitchAbstract()->sendRawMessage(
ctx.words.mid(1).join(" "));
getApp()->getTwitch()->sendRawMessage(ctx.words.mid(1).join(" "));
}
else
{
Expand Down Expand Up @@ -564,7 +563,7 @@ QString injectFakeMessage(const CommandContext &ctx)
}

auto ircText = ctx.words.mid(1).join(" ");
getApp()->getTwitchAbstract()->addFakeMessage(ircText);
getApp()->getTwitch()->addFakeMessage(ircText);

return "";
}
Expand Down Expand Up @@ -663,7 +662,7 @@ QString openUsercard(const CommandContext &ctx)
stripChannelName(channelName);

ChannelPtr channelTemp =
getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
getApp()->getTwitch()->getChannelOrEmpty(channelName);

if (channelTemp->isEmpty())
{
Expand Down
7 changes: 3 additions & 4 deletions src/controllers/commands/builtin/twitch/SendWhisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,9 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
!(getSettings()->streamerModeSuppressInlineWhispers &&
getApp()->getStreamerMode()->isEnabled()))
{
app->getTwitchAbstract()->forEachChannel(
[&messagexD](ChannelPtr _channel) {
_channel->addMessage(messagexD, MessageContext::Repost);
});
app->getTwitch()->forEachChannel([&messagexD](ChannelPtr _channel) {
_channel->addMessage(messagexD, MessageContext::Repost);
});
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/notifications/NotificationController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void NotificationController::fetchFakeChannels()
for (size_t i = 0; i < channelMap[Platform::Twitch].raw().size(); i++)
{
const auto &name = channelMap[Platform::Twitch].raw()[i];
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(name);
auto chan = getApp()->getTwitch()->getChannelOrEmpty(name);
if (chan->isEmpty())
{
channels.push_back(name);
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/plugins/api/ChannelRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ int ChannelRef::get_by_name(lua_State *L)
lua_pushnil(L);
return 1;
}
auto chn = getApp()->getTwitchAbstract()->getChannelOrEmpty(name);
auto chn = getApp()->getTwitch()->getChannelOrEmpty(name);
lua::push(L, chn);
return 1;
}
Expand Down
19 changes: 9 additions & 10 deletions src/providers/twitch/IrcMessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
{
return;
}
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
auto chan = getApp()->getTwitch()->getChannelOrEmpty(chanName);

auto *twitchChannel = dynamic_cast<TwitchChannel *>(chan.get());
if (!twitchChannel)
Expand Down Expand Up @@ -794,7 +794,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
}

// get channel
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
auto chan = getApp()->getTwitch()->getChannelOrEmpty(chanName);

if (chan->isEmpty())
{
Expand Down Expand Up @@ -839,7 +839,7 @@ void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
}

// get channel
auto chan = getApp()->getTwitchAbstract()->getChannelOrEmpty(chanName);
auto chan = getApp()->getTwitch()->getChannelOrEmpty(chanName);

if (chan->isEmpty())
{
Expand Down Expand Up @@ -887,7 +887,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
return;
}

auto c = getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
auto c = getApp()->getTwitch()->getChannelOrEmpty(channelName);
if (c->isEmpty())
{
return;
Expand Down Expand Up @@ -976,8 +976,8 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *ircMessage)
!(getSettings()->streamerModeSuppressInlineWhispers &&
getApp()->getStreamerMode()->isEnabled()))
{
getApp()->getTwitchAbstract()->forEachChannel([&message, overrideFlags](
ChannelPtr channel) {
getApp()->getTwitch()->forEachChannel([&message, overrideFlags](
ChannelPtr channel) {
channel->addMessage(message, MessageContext::Repost, overrideFlags);
});
}
Expand Down Expand Up @@ -1119,8 +1119,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
return;
}

auto channel =
getApp()->getTwitchAbstract()->getChannelOrEmpty(channelName);
auto channel = getApp()->getTwitch()->getChannelOrEmpty(channelName);

if (channel->isEmpty())
{
Expand Down Expand Up @@ -1202,7 +1201,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)

void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
{
auto channel = getApp()->getTwitchAbstract()->getChannelOrEmpty(
auto channel = getApp()->getTwitch()->getChannelOrEmpty(
message->parameter(0).remove(0, 1));

auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
Expand All @@ -1225,7 +1224,7 @@ void IrcMessageHandler::handleJoinMessage(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));

auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
Expand Down
2 changes: 1 addition & 1 deletion src/providers/twitch/TwitchChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ bool TwitchChannel::canReconnect() const

void TwitchChannel::reconnect()
{
getApp()->getTwitchAbstract()->connect();
getApp()->getTwitch()->connect();
}

QString TwitchChannel::getCurrentStreamID() const
Expand Down
7 changes: 3 additions & 4 deletions src/singletons/NativeMessaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void NativeMessagingServer::ReceiverThread::handleSelect(
postToThread([=] {
if (!name.isEmpty())
{
auto channel = getApp()->getTwitchAbstract()->getOrAddChannel(name);
auto channel = getApp()->getTwitch()->getOrAddChannel(name);
if (getApp()->getTwitch()->getWatchingChannel().get() != channel)
{
getApp()->getTwitch()->setWatchingChannel(channel);
Expand All @@ -268,7 +268,7 @@ void NativeMessagingServer::ReceiverThread::handleSelect(
if (!name.isEmpty())
{
window->setChannel(
getApp()->getTwitchAbstract()->getOrAddChannel(name));
getApp()->getTwitch()->getOrAddChannel(name));
}
#endif
}
Expand Down Expand Up @@ -319,8 +319,7 @@ void NativeMessagingServer::syncChannels(const QJsonArray &twitchChannels)
continue;
}
// the deduping is done on the extension side
updated.emplace_back(
getApp()->getTwitchAbstract()->getOrAddChannel(name));
updated.emplace_back(getApp()->getTwitch()->getOrAddChannel(name));
}

// This will destroy channels that aren't used anymore.
Expand Down
4 changes: 2 additions & 2 deletions src/singletons/StreamerMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool isBroadcasterSoftwareActive()
shouldShowTimeoutWarning = false;

postToThread([] {
getApp()->getTwitchAbstract()->addGlobalSystemMessage(
getApp()->getTwitch()->addGlobalSystemMessage(
"Streamer Mode is set to Automatic, but pgrep timed "
"out. This can happen if your system lagged at the "
"wrong moment. If Streamer Mode continues to not work, "
Expand All @@ -94,7 +94,7 @@ bool isBroadcasterSoftwareActive()
shouldShowWarning = false;

postToThread([] {
getApp()->getTwitchAbstract()->addGlobalSystemMessage(
getApp()->getTwitch()->addGlobalSystemMessage(
"Streamer Mode is set to Automatic, but pgrep is "
"missing. "
"Install it to fix the issue or set Streamer Mode to "
Expand Down
5 changes: 2 additions & 3 deletions src/singletons/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,7 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)

if (descriptor.type_ == "twitch")
{
return getApp()->getTwitchAbstract()->getOrAddChannel(
descriptor.channelName_);
return getApp()->getTwitch()->getOrAddChannel(descriptor.channelName_);
}
else if (descriptor.type_ == "mentions")
{
Expand All @@ -693,7 +692,7 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
}
else if (descriptor.type_ == "misc")
{
return getApp()->getTwitchAbstract()->getChannelOrEmpty(
return getApp()->getTwitch()->getChannelOrEmpty(
descriptor.channelName_);
}

Expand Down
3 changes: 1 addition & 2 deletions src/widgets/FramelessEmbedWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ bool FramelessEmbedWindow::nativeEvent(const QByteArray &eventType,
auto channelName = root.value("channel-name").toString();

this->split_->setChannel(
getApp()->getTwitchAbstract()->getOrAddChannel(
channelName));
getApp()->getTwitch()->getOrAddChannel(channelName));
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/widgets/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,23 +261,23 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
const auto &messages = getSampleMiscMessages();
static int index = 0;
const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg);
getApp()->getTwitch()->addFakeMessage(msg);
return "";
});

actions.emplace("addCheerMessage", [=](std::vector<QString>) -> QString {
const auto &messages = getSampleCheerMessages();
static int index = 0;
const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg);
getApp()->getTwitch()->addFakeMessage(msg);
return "";
});

actions.emplace("addLinkMessage", [=](std::vector<QString>) -> QString {
const auto &messages = getSampleLinkMessages();
static int index = 0;
const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg);
getApp()->getTwitch()->addFakeMessage(msg);
return "";
});

Expand All @@ -292,7 +292,7 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
oMessage->toInner<PubSubMessageMessage>()
->toInner<PubSubCommunityPointsChannelV1Message>();

getApp()->getTwitchAbstract()->addFakeMessage(
getApp()->getTwitch()->addFakeMessage(
getSampleChannelRewardIRCMessage());
getApp()->getTwitchPubSub()->pointReward.redeemed.invoke(
oInnerMessage->data.value("redemption").toObject());
Expand All @@ -316,15 +316,15 @@ void Window::addDebugStuff(HotkeyController::HotkeyMap &actions)
const auto &messages = getSampleEmoteTestMessages();
static int index = 0;
const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg);
getApp()->getTwitch()->addFakeMessage(msg);
return "";
});

actions.emplace("addSubMessage", [=](std::vector<QString>) -> QString {
const auto &messages = getSampleSubMessages();
static int index = 0;
const auto &msg = messages[index++ % messages.size()];
getApp()->getTwitchAbstract()->addFakeMessage(msg);
getApp()->getTwitch()->addFakeMessage(msg);
return "";
});
#endif
Expand Down Expand Up @@ -487,8 +487,8 @@ void Window::addShortcuts()
splitContainer = this->notebook_->getOrAddSelectedPage();
}
Split *split = new Split(splitContainer);
split->setChannel(getApp()->getTwitchAbstract()->getOrAddChannel(
si.channelName));
split->setChannel(
getApp()->getTwitch()->getOrAddChannel(si.channelName));
split->setFilters(si.filters);
splitContainer->insertSplit(split);
splitContainer->setSelected(split);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dialogs/SelectChannelDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
case TAB_TWITCH: {
if (this->ui_.twitch.channel->isChecked())
{
return getApp()->getTwitchAbstract()->getOrAddChannel(
return getApp()->getTwitch()->getOrAddChannel(
this->ui_.twitch.channelName->text().trimmed());
}
else if (this->ui_.twitch.watching->isChecked())
Expand Down
7 changes: 3 additions & 4 deletions src/widgets/dialogs/UserInfoPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,15 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
.getOrAddSelectedPage()
->appendNewSplit(false);
split->setChannel(
app->getTwitchAbstract()->getOrAddChannel(
app->getTwitch()->getOrAddChannel(
loginName.toLower()));
});

menu->addAction(
"Open channel in a new tab", this, [loginName] {
ChannelPtr channel =
getApp()
->getTwitchAbstract()
->getOrAddChannel(loginName);
getApp()->getTwitch()->getOrAddChannel(
loginName);
auto &nb = getApp()
->getWindows()
->getMainWindow()
Expand Down
3 changes: 1 addition & 2 deletions src/widgets/dialogs/switcher/NewPopupItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ NewPopupItem::NewPopupItem(const QString &channelName)

void NewPopupItem::action()
{
auto channel =
getApp()->getTwitchAbstract()->getOrAddChannel(this->channelName_);
auto channel = getApp()->getTwitch()->getOrAddChannel(this->channelName_);
getApp()->getWindows()->openInPopup(channel);
}

Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dialogs/switcher/NewTabItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void NewTabItem::action()

Split *split = new Split(container);
split->setChannel(
getApp()->getTwitchAbstract()->getOrAddChannel(this->channelName_));
getApp()->getTwitch()->getOrAddChannel(this->channelName_));
container->insertSplit(split);
}

Expand Down
Loading

0 comments on commit ac88730

Please sign in to comment.