From fba29677770bc797aea0b0c7c25107fb1f4e2194 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 31 Mar 2018 13:59:17 +0200 Subject: [PATCH] Re-fix timeout message merging Fix #298 --- src/messages/message.cpp | 5 +++-- src/providers/twitch/ircmessagehandler.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/messages/message.cpp b/src/messages/message.cpp index f3ebd5b44..d2fca598d 100644 --- a/src/messages/message.cpp +++ b/src/messages/message.cpp @@ -31,7 +31,7 @@ MessagePtr Message::createSystemMessage(const QString &text) message->addElement(new TimestampElement(QTime::currentTime())); message->addElement(new TextElement(text, MessageElement::Text, MessageColor::System)); - message->flags |= MessageFlags::System; + message->flags.EnableFlag(MessageFlags::System); message->searchText = text; return message; @@ -72,7 +72,8 @@ MessagePtr Message::createTimeoutMessage(const QString &username, const QString } MessagePtr message = Message::createSystemMessage(text); - message->flags |= MessageFlags::System; + message->flags.EnableFlag(MessageFlags::System); + message->flags.EnableFlag(MessageFlags::Timeout); message->timeoutUser = username; return message; } diff --git a/src/providers/twitch/ircmessagehandler.cpp b/src/providers/twitch/ircmessagehandler.cpp index d1ab09f23..ea493e3dd 100644 --- a/src/providers/twitch/ircmessagehandler.cpp +++ b/src/providers/twitch/ircmessagehandler.cpp @@ -104,10 +104,11 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message) int snapshotLength = snapshot.getLength(); for (int i = std::max(0, snapshotLength - 20); i < snapshotLength; i++) { - if (snapshot[i]->flags & Message::Timeout && snapshot[i]->loginName == username) { + auto &s = snapshot[i]; + if (s->flags.HasFlag(Message::Timeout) && s->timeoutUser == username) { MessagePtr replacement( Message::createTimeoutMessage(username, durationInSeconds, reason, true)); - chan->replaceMessage(snapshot[i], replacement); + chan->replaceMessage(s, replacement); addMessage = false; break; }