Clearchat now disables previous messages

Fix #499
This commit is contained in:
Rasmus Karlsson 2018-06-22 21:44:02 +00:00
parent dd0d6a0f88
commit 115031b7ac
3 changed files with 16 additions and 0 deletions

View file

@ -150,6 +150,20 @@ void Channel::addOrReplaceTimeout(messages::MessagePtr message)
// WindowManager::getInstance().repaintVisibleChatWidgets(this);
}
void Channel::disableAllMessages()
{
LimitedQueueSnapshot<MessagePtr> snapshot = this->getMessageSnapshot();
int snapshotLength = snapshot.getLength();
for (int i = 0; i < snapshotLength; i++) {
auto &s = snapshot[i];
if (s->flags & Message::System || s->flags & Message::Timeout) {
continue;
}
s->flags.EnableFlag(Message::Disabled);
}
}
void Channel::addMessagesAtStart(std::vector<messages::MessagePtr> &_messages)
{
std::vector<messages::MessagePtr> addedMessages = this->messages.pushFront(_messages);

View file

@ -51,6 +51,7 @@ public:
void addMessage(messages::MessagePtr message);
void addMessagesAtStart(std::vector<messages::MessagePtr> &messages);
void addOrReplaceTimeout(messages::MessagePtr message);
void disableAllMessages();
void replaceMessage(messages::MessagePtr message, messages::MessagePtr replacement);
virtual void addRecentChatter(const std::shared_ptr<messages::Message> &message);

View file

@ -150,6 +150,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
// check if the chat has been cleared by a moderator
if (message->parameters().length() == 1) {
chan->disableAllMessages();
chan->addMessage(Message::createSystemMessage("Chat has been cleared by a moderator."));
return;