diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index b7247a462..516918f70 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -6,6 +6,7 @@ #include "messages/MessageBuilder.hpp" #include "singletons/Emotes.hpp" #include "singletons/Logging.hpp" +#include "singletons/Settings.hpp" #include "singletons/WindowManager.hpp" #include @@ -102,6 +103,9 @@ void Channel::addOrReplaceTimeout(MessagePtr message) QTime minimumTime = QTime::currentTime().addSecs(-5); + auto timeoutStackStyle = static_cast( + getSettings()->timeoutStackStyle.getValue()); + for (int i = snapshotLength - 1; i >= end; --i) { auto &s = snapshot[i]; @@ -117,6 +121,16 @@ void Channel::addOrReplaceTimeout(MessagePtr message) break; } + if (timeoutStackStyle == TimeoutStackStyle::DontStackBeyondUserMessage) + { + if (s->loginName == message->timeoutUser && + s->flags.hasNone({MessageFlag::Disabled, MessageFlag::Timeout, + MessageFlag::Untimeout})) + { + break; + } + } + if (s->flags.has(MessageFlag::Timeout) && s->timeoutUser == message->timeoutUser) // { diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index 9abc668ea..409eb0f54 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -18,6 +18,13 @@ using MessagePtr = std::shared_ptr; enum class MessageFlag : uint32_t; using MessageFlags = FlagsEnum; +enum class TimeoutStackStyle : int { + StackHard = 0, + DontStackBeyondUserMessage = 1, + + Default = StackHard, +}; + class Channel : public std::enable_shared_from_this { public: diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 0d71fbccd..fc42201e3 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -2,6 +2,7 @@ #include "BaseSettings.hpp" +#include "common/Channel.hpp" #include "controllers/highlights/HighlightPhrase.hpp" #include "controllers/moderationactions/ModerationAction.hpp" #include "singletons/Toasts.hpp" @@ -129,6 +130,9 @@ public: /// Moderation QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"}; + IntSetting timeoutStackStyle = { + "/moderation/timeoutStackStyle", + static_cast(TimeoutStackStyle::Default)}; /// Highlighting // BoolSetting enableHighlights = {"/highlighting/enabled", true}; diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 9448e38b7..3316850db 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -217,6 +217,10 @@ void GeneralPage::initLayout(SettingsLayout &layout) // layout.addDropdown("Last read message style", {"Default"}); layout.addCheckbox("Hide moderated messages", s.hideModerated); layout.addCheckbox("Hide moderation messages", s.hideModerationActions); + layout.addDropdown( + "Timeout stacking style", {"Stack", "Stack sparingly"}, + s.timeoutStackStyle, [](int index) { return index; }, + [](auto args) { return args.index; }, false); layout.addTitle("Emotes"); layout.addDropdown(