Delete 'is live' messages from non-open channels (#3678)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL
2022-04-30 11:37:24 +00:00
committed by GitHub
parent d85d9d4910
commit 00b463d298
2 changed files with 21 additions and 0 deletions
@@ -249,6 +249,26 @@ void NotificationController::removeFakeChannel(const QString channelName)
if (i != fakeTwitchChannels.end())
{
fakeTwitchChannels.erase(i);
// "delete" old 'CHANNEL is live' message
LimitedQueueSnapshot<MessagePtr> snapshot =
getApp()->twitch->liveChannel->getMessageSnapshot();
int snapshotLength = snapshot.size();
// MSVC hates this code if the parens are not there
int end = (std::max)(0, snapshotLength - 200);
// this assumes that channelName is a login name therefore will only delete messages from fake channels
auto liveMessageSearchText = QString("%1 is live!").arg(channelName);
for (int i = snapshotLength - 1; i >= end; --i)
{
auto &s = snapshot[i];
if (s->messageText == liveMessageSearchText)
{
s->flags.set(MessageFlag::Disabled);
break;
}
}
}
}