chore: refactor TwitchIrcServer (#5421)

This commit is contained in:
pajlada
2024-06-01 14:56:40 +02:00
committed by GitHub
parent 2a46ee708e
commit b6dc5d9e03
28 changed files with 373 additions and 163 deletions
+8 -9
View File
@@ -236,14 +236,13 @@ void NativeMessagingServer::ReceiverThread::handleSelect(
}
postToThread([=] {
auto *app = getApp();
if (!name.isEmpty())
{
auto channel = app->twitch->getOrAddChannel(name);
if (app->twitch->watchingChannel.get() != channel)
auto channel =
getIApp()->getTwitchAbstract()->getOrAddChannel(name);
if (getIApp()->getTwitch()->getWatchingChannel().get() != channel)
{
app->twitch->watchingChannel.reset(channel);
getIApp()->getTwitch()->setWatchingChannel(channel);
}
}
@@ -253,7 +252,8 @@ void NativeMessagingServer::ReceiverThread::handleSelect(
auto *window = AttachedWindow::getForeground(args);
if (!name.isEmpty())
{
window->setChannel(app->twitch->getOrAddChannel(name));
window->setChannel(
getIApp()->getTwitchAbstract()->getOrAddChannel(name));
}
#endif
}
@@ -294,8 +294,6 @@ void NativeMessagingServer::syncChannels(const QJsonArray &twitchChannels)
{
assertInGuiThread();
auto *app = getApp();
std::vector<ChannelPtr> updated;
updated.reserve(twitchChannels.size());
for (const auto &value : twitchChannels)
@@ -306,7 +304,8 @@ void NativeMessagingServer::syncChannels(const QJsonArray &twitchChannels)
continue;
}
// the deduping is done on the extension side
updated.emplace_back(app->twitch->getOrAddChannel(name));
updated.emplace_back(
getIApp()->getTwitchAbstract()->getOrAddChannel(name));
}
// This will destroy channels that aren't used anymore.