From 3214e0a80b0a204dbab0c26f63f7eb94b5c11707 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sat, 25 Jan 2025 11:42:55 +0100 Subject: [PATCH] fix: more force relayout on timeout/clear/delete (#5854) --- CHANGELOG.md | 2 +- src/common/Channel.cpp | 15 --------------- src/providers/twitch/IrcMessageHandler.cpp | 11 ++++++----- src/providers/twitch/TwitchIrcServer.cpp | 12 ++++++++++++ src/singletons/WindowManager.cpp | 3 +++ src/util/VectorMessageSink.cpp | 5 ++++- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d77b7424..52cb3343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ - Bugfix: Fixed tabs not scaling to the default scale when changing the scale from a non-default value. (#5794) - Bugfix: Closing a usercard will no longer cause stop-logging messages to be generated in channel logs. (#5828) - Bugfix: Fixed tabs not scaling to the default scale when changing the scale from a non-default value. (#5794, #5833) -- Bugfix: Fixed deleted messages not disappearing when "Hide deleted messages" is enabled. (#5844) +- Bugfix: Fixed deleted messages not immediately disappearing when "Hide deleted messages" is enabled. (#5844, #5854) - Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784) - Dev: Updated Conan dependencies. (#5776) - Dev: Replaced usage of `parseTime` with `serverReceivedTime` for clearchat messages. (#5824) diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index cfe6b37c..13b82816 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -4,22 +4,10 @@ #include "messages/Message.hpp" #include "messages/MessageBuilder.hpp" #include "messages/MessageSimilarity.hpp" -#include "providers/twitch/IrcMessageHandler.hpp" -#include "providers/twitch/TwitchIrcServer.hpp" -#include "singletons/Emotes.hpp" #include "singletons/Logging.hpp" #include "singletons/Settings.hpp" -#include "singletons/WindowManager.hpp" #include "util/ChannelHelpers.hpp" -#include -#include -#include -#include -#include -#include -#include - namespace chatterino { // @@ -135,9 +123,6 @@ void Channel::addOrReplaceTimeout(MessagePtr message, const QDateTime &now) this->addMessage(msg, MessageContext::Original); }, true); - - // XXX: Might need the following line - // WindowManager::instance().repaintVisibleChatWidgets(this); } void Channel::addOrReplaceClearChat(MessagePtr message, const QDateTime &now) diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index e58cc0f7..6601fa12 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -468,15 +468,16 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message) { chan->disableAllMessages(); chan->addOrReplaceClearChat(std::move(clearChat.message), time); - return; + } + else + { + chan->addOrReplaceTimeout(std::move(clearChat.message), time); } - chan->addOrReplaceTimeout(std::move(clearChat.message), time); - - // refresh all - getApp()->getWindows()->repaintVisibleChatWidgets(chan.get()); if (getSettings()->hideModerated) { + // XXX: This is expensive. We could use a layout request if the layout + // would store the previous message flags. getApp()->getWindows()->forceLayoutChannelViews(); } } diff --git a/src/providers/twitch/TwitchIrcServer.cpp b/src/providers/twitch/TwitchIrcServer.cpp index f1cc50c4..3f8bc534 100644 --- a/src/providers/twitch/TwitchIrcServer.cpp +++ b/src/providers/twitch/TwitchIrcServer.cpp @@ -252,6 +252,12 @@ void TwitchIrcServer::initialize() auto now = QDateTime::currentDateTime(); chan->addOrReplaceClearChat( MessageBuilder::makeClearChatMessage(now, actor), now); + if (getSettings()->hideModerated) + { + // XXX: This is expensive. We could use a layout request if the layout + // would store the previous message flags. + getApp()->getWindows()->forceLayoutChannelViews(); + } }); }); @@ -317,6 +323,12 @@ void TwitchIrcServer::initialize() msg->flags.set(MessageFlag::PubSub); chan->addOrReplaceTimeout(msg.release(), QDateTime::currentDateTime()); + if (getSettings()->hideModerated) + { + // XXX: This is expensive. We could use a layout request if the layout + // would store the previous message flags. + getApp()->getWindows()->forceLayoutChannelViews(); + } }); }); diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index b95ff357..089a2fa4 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -144,6 +144,9 @@ WindowManager::WindowManager(const Paths &paths, Settings &settings, this->forceLayoutChannelViewsListener.add(settings.boldUsernames); this->forceLayoutChannelViewsListener.add( settings.showBlockedTermAutomodMessages); + this->forceLayoutChannelViewsListener.add(settings.hideModerated); + this->forceLayoutChannelViewsListener.add( + settings.streamerModeHideModActions); this->layoutChannelViewsListener.add(settings.timestampFormat); this->layoutChannelViewsListener.add(fonts.fontChanged); diff --git a/src/util/VectorMessageSink.cpp b/src/util/VectorMessageSink.cpp index 5286a2ad..85261105 100644 --- a/src/util/VectorMessageSink.cpp +++ b/src/util/VectorMessageSink.cpp @@ -10,7 +10,10 @@ namespace chatterino { VectorMessageSink::VectorMessageSink(MessageSinkTraits traits, MessageFlags additionalFlags) : additionalFlags(additionalFlags) - , traits(traits){}; + , traits(traits) +{ +} + VectorMessageSink::~VectorMessageSink() = default; void VectorMessageSink::addMessage(MessagePtr message, MessageContext ctx,