chore: move some Channel signals to TwitchChannel (#6787)

Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Nerixyz
2026-01-31 16:33:32 +01:00
committed by GitHub
parent 8f660b6de5
commit 301417488f
6 changed files with 46 additions and 27 deletions
+1
View File
@@ -104,6 +104,7 @@
- Dev: Remove unused `reloadChannelAndSubscriberEmotes`. (#6756)
- Dev: Refactored `DebugCount`. (#6753)
- Dev: Moved `PluginMeta` to its own file. (#6757)
- Dev: Moves some `Channel` signals to `TwitchChannel`. (#6787)
## 2.5.4
-1
View File
@@ -37,7 +37,6 @@ Channel::~Channel()
{
app->getChatLogger()->closeChannel(this->name_, this->platform_);
}
this->destroyed.invoke();
}
Channel::Type Channel::getType() const
-6
View File
@@ -61,11 +61,6 @@ public:
~Channel() override;
// SIGNALS
pajlada::Signals::Signal<const QString &, const QString &, bool &>
sendMessageSignal;
pajlada::Signals::Signal<const QString &, const QString &, const QString &,
bool &>
sendReplySignal;
pajlada::Signals::Signal<MessagePtr &, std::optional<MessageFlags>>
messageAppended;
pajlada::Signals::Signal<std::vector<MessagePtr> &> messagesAddedAtStart;
@@ -74,7 +69,6 @@ public:
messageReplaced;
/// Invoked when some number of messages were filled in using time received
pajlada::Signals::Signal<const std::vector<MessagePtr> &> filledInMessages;
pajlada::Signals::NoArgSignal destroyed;
pajlada::Signals::NoArgSignal displayNameChanged;
pajlada::Signals::NoArgSignal messagesCleared;
+4 -3
View File
@@ -240,6 +240,8 @@ TwitchChannel::~TwitchChannel()
getApp()->getSeventvEventAPI()->unsubscribeTwitchChannel(
this->roomId());
}
this->destroyed.invoke();
}
void TwitchChannel::initialize()
@@ -834,7 +836,7 @@ void TwitchChannel::sendMessage(const QString &message)
}
bool messageSent = false;
this->sendMessageSignal.invoke(this->getName(), parsedMessage, messageSent);
this->sendMessageSignal.invoke(parsedMessage, messageSent);
this->updateBttvActivity();
this->updateSevenTVActivity();
@@ -876,8 +878,7 @@ void TwitchChannel::sendReply(const QString &message, const QString &replyId)
}
bool messageSent = false;
this->sendReplySignal.invoke(this->getName(), parsedMessage, replyId,
messageSent);
this->sendReplySignal.invoke(parsedMessage, replyId, messageSent);
if (messageSent)
{
+23
View File
@@ -297,6 +297,27 @@ public:
*/
std::shared_ptr<MessageThread> getOrCreateThread(const MessagePtr &message);
/// Fired when a message is supposed to be sent by the user in this channel.
///
/// This should only be handled by one component.
///
/// Arguments:
/// - `messageText`: The text to be sent.
/// - `wasSent`: A return channel for whether the message was sent or not.
pajlada::Signals::Signal<const QString &, bool &> sendMessageSignal;
/// Fired when a reply to a message is supposed to be sent by the user in
/// this channel.
///
/// This should only be handled by one component.
///
/// Arguments:
/// - `messageText`: The text to be sent.
/// - `replyToMessageID`: The ID of the replied-to message.
/// - `wasSent`: A return channel for whether the message was sent or not.
pajlada::Signals::Signal<const QString &, const QString &, bool &>
sendReplySignal;
/**
* This signal fires when the local user has joined the channel
**/
@@ -315,6 +336,8 @@ public:
pajlada::Signals::NoArgSignal roomModesChanged;
pajlada::Signals::NoArgSignal destroyed;
// Channel point rewards
void addQueuedRedemption(const QString &rewardId,
const QString &originalContent,
+18 -17
View File
@@ -321,8 +321,7 @@ std::shared_ptr<Channel> TwitchIrcServer::createChannel(
// no Channel's should live
// NOTE: CHANNEL_LIFETIME
std::ignore = channel->sendMessageSignal.connect(
[this, channel = std::weak_ptr(channel)](auto &chan, auto &msg,
bool &sent) {
[this, channel = std::weak_ptr(channel)](auto &msg, bool &sent) {
auto c = channel.lock();
if (!c)
{
@@ -331,8 +330,8 @@ std::shared_ptr<Channel> TwitchIrcServer::createChannel(
this->onMessageSendRequested(c, msg, sent);
});
std::ignore = channel->sendReplySignal.connect(
[this, channel = std::weak_ptr(channel)](auto &chan, auto &msg,
auto &replyId, bool &sent) {
[this, channel = std::weak_ptr(channel)](auto &msg, auto &replyId,
bool &sent) {
auto c = channel.lock();
if (!c)
{
@@ -1155,28 +1154,30 @@ ChannelPtr TwitchIrcServer::getOrAddChannel(const QString &dirtyChannelName)
// value doesn't exist
chan = this->createChannel(channelName);
if (!chan)
auto *twitchChannel = dynamic_cast<TwitchChannel *>(chan.get());
if (!chan || !twitchChannel)
{
return Channel::getEmpty();
}
this->channels.insert(channelName, chan);
this->signalHolder.managedConnect(chan->destroyed, [this, channelName] {
// fourtf: issues when the server itself is destroyed
this->signalHolder.managedConnect(
twitchChannel->destroyed, [this, channelName] {
// fourtf: issues when the server itself is destroyed
qCDebug(chatterinoIrc) << "[TwitchIrcServer::addChannel]" << channelName
<< "was destroyed";
this->channels.remove(channelName);
qCDebug(chatterinoIrc) << "[TwitchIrcServer::addChannel]"
<< channelName << "was destroyed";
this->channels.remove(channelName);
if (this->readConnection_)
{
// HACK(mm2pl): This prevents custom invalid twitch channels used by plugins from being joined
if (!channelName.startsWith("/"))
if (this->readConnection_)
{
this->readConnection_->sendRaw("PART #" + channelName);
// HACK(mm2pl): This prevents custom invalid twitch channels used by plugins from being joined
if (!channelName.startsWith("/"))
{
this->readConnection_->sendRaw("PART #" + channelName);
}
}
}
});
});
// join IRC channel
{