From 010c061a254571fe0741bb7f22a3ca49971fcf7c Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 31 Mar 2018 11:32:29 +0200 Subject: [PATCH] Fixes the previous "Disabled message" behaviour Fixes #295 --- src/messages/layouts/messagelayout.cpp | 2 +- src/messages/message.hpp | 4 +++- src/providers/twitch/ircmessagehandler.cpp | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/messages/layouts/messagelayout.cpp b/src/messages/layouts/messagelayout.cpp index baed03814..dd348fd92 100644 --- a/src/messages/layouts/messagelayout.cpp +++ b/src/messages/layouts/messagelayout.cpp @@ -152,7 +152,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection // painter.drawPixmap(0, y, this->container.width, this->container.getHeight(), *pixmap); // draw disabled - if (this->message->flags & Message::Disabled) { + if (this->message->flags.HasFlag(Message::Disabled)) { painter.fillRect(0, y, pixmap->width(), pixmap->height(), themeManager.messages.disabled); } diff --git a/src/messages/message.hpp b/src/messages/message.hpp index 3a6b1bcea..341d6a4a4 100644 --- a/src/messages/message.hpp +++ b/src/messages/message.hpp @@ -12,6 +12,7 @@ namespace chatterino { namespace messages { + struct Message { enum MessageFlags : uint16_t { None = 0, @@ -53,6 +54,7 @@ public: const QString &reason, bool multipleTimes); }; -typedef std::shared_ptr MessagePtr; +using MessagePtr = std::shared_ptr; + } // namespace messages } // namespace chatterino diff --git a/src/providers/twitch/ircmessagehandler.cpp b/src/providers/twitch/ircmessagehandler.cpp index 421e70aad..d1ab09f23 100644 --- a/src/providers/twitch/ircmessagehandler.cpp +++ b/src/providers/twitch/ircmessagehandler.cpp @@ -119,8 +119,9 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message) // disable the messages from the user for (int i = 0; i < snapshotLength; i++) { - if (!(snapshot[i]->flags & Message::Timeout) && snapshot[i]->loginName == username) { - snapshot[i]->flags &= Message::Disabled; + auto &s = snapshot[i]; + if (!(s->flags & Message::Timeout) && s->loginName == username) { + s->flags.EnableFlag(Message::Disabled); } }