Re-fix timeout message merging

Fix #298
This commit is contained in:
Rasmus Karlsson 2018-03-31 13:59:17 +02:00
parent be66338fe2
commit fdea4f32f0
2 changed files with 6 additions and 4 deletions

View file

@ -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;
}

View file

@ -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;
}