feat: prefer visible/selected channels when joining (#5850)

This commit is contained in:
nerix
2025-01-24 12:43:30 +01:00
committed by GitHub
parent f4ff62f908
commit 35b15c4088
4 changed files with 48 additions and 13 deletions
+1
View File
@@ -6,6 +6,7 @@
- Minor: Treat all browsers starting with `firefox` as a Firefox browser. (#5805)
- Minor: Remove incognito browser support for `opera/launcher` (this should no longer be a thing). (#5805)
- Minor: Remove incognito browser support for `iexplore`, because internet explorer is EOL. (#5810)
- Minor: When (re-)connecting, visible channels are now joined first. (#5850)
- Bugfix: Fixed a potential way to escape the Lua Plugin sandbox. (#5846)
- Bugfix: Fixed a crash relating to Lua HTTP. (#5800)
- Bugfix: Fixed a crash that could occur on Linux and macOS when clicking "Install" from the update prompt. (#5818)
+24 -13
View File
@@ -24,6 +24,7 @@
#include "providers/twitch/TwitchChannel.hpp"
#include "singletons/Settings.hpp"
#include "singletons/StreamerMode.hpp"
#include "singletons/WindowManager.hpp"
#include "util/PostToThread.hpp"
#include "util/RatelimitBucket.hpp"
@@ -935,15 +936,31 @@ void TwitchIrcServer::onReadConnected(IrcConnection *connection)
{
(void)connection;
std::lock_guard lock(this->channelMutex);
std::vector<ChannelPtr> activeChannels;
{
std::lock_guard lock(this->channelMutex);
activeChannels.reserve(this->channels.size());
for (const auto &weak : this->channels)
{
if (auto channel = weak.lock())
{
activeChannels.push_back(channel);
}
}
}
// put the visible channels first
auto visible = getApp()->getWindows()->getVisibleChannelNames();
std::ranges::stable_partition(activeChannels, [&](const auto &chan) {
return visible.contains(chan->getName());
});
// join channels
for (auto &&weak : this->channels)
for (const auto &channel : activeChannels)
{
if (auto channel = weak.lock())
{
this->joinBucket_->send(channel->getName());
}
this->joinBucket_->send(channel->getName());
}
// connected/disconnected message
@@ -952,14 +969,8 @@ void TwitchIrcServer::onReadConnected(IrcConnection *connection)
auto reconnected = makeSystemMessage("reconnected");
reconnected->flags.set(MessageFlag::ConnectedMessage);
for (std::weak_ptr<Channel> &weak : this->channels.values())
for (const auto &chan : activeChannels)
{
std::shared_ptr<Channel> chan = weak.lock();
if (!chan)
{
continue;
}
LimitedQueueSnapshot<MessagePtr> snapshot = chan->getMessageSnapshot();
bool replaceMessage =
+20
View File
@@ -595,6 +595,26 @@ void WindowManager::toggleAllOverlayInertia()
}
}
std::set<QString> WindowManager::getVisibleChannelNames() const
{
std::set<QString> visible;
for (auto *window : this->windows_)
{
auto *page = window->getNotebook().getSelectedPage();
if (!page)
{
continue;
}
for (auto *split : page->getSplits())
{
visible.emplace(split->getChannel()->getName());
}
}
return visible;
}
void WindowManager::encodeTab(SplitContainer *tab, bool isSelected,
QJsonObject &obj)
{
+3
View File
@@ -9,6 +9,7 @@
#include <QTimer>
#include <memory>
#include <set>
namespace chatterino {
@@ -131,6 +132,8 @@ public:
/// Toggles the inertia in all open overlay windows
void toggleAllOverlayInertia();
std::set<QString> getVisibleChannelNames() const;
/// Signals
pajlada::Signals::NoArgSignal gifRepaintRequested;