Add a setting for the timeout stack style:

"Stack" is the default behaviour, it will search 20 messages up and 5
seconds back in time to stack the timeout.
"Stack sparingly" will try to do the same, but only if the user has not
typed a message inbetween the this and the last timeout.

Fixes #1157
This commit is contained in:
Rasmus Karlsson
2019-07-28 13:19:17 +02:00
parent ba1a56c3b7
commit 954b1b138a
4 changed files with 29 additions and 0 deletions
+14
View File
@@ -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 <QJsonArray>
@@ -102,6 +103,9 @@ void Channel::addOrReplaceTimeout(MessagePtr message)
QTime minimumTime = QTime::currentTime().addSecs(-5);
auto timeoutStackStyle = static_cast<TimeoutStackStyle>(
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) //
{
+7
View File
@@ -18,6 +18,13 @@ using MessagePtr = std::shared_ptr<const Message>;
enum class MessageFlag : uint32_t;
using MessageFlags = FlagsEnum<MessageFlag>;
enum class TimeoutStackStyle : int {
StackHard = 0,
DontStackBeyondUserMessage = 1,
Default = StackHard,
};
class Channel : public std::enable_shared_from_this<Channel>
{
public:
+4
View File
@@ -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<int>(TimeoutStackStyle::Default)};
/// Highlighting
// BoolSetting enableHighlights = {"/highlighting/enabled", true};
@@ -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<int>(
"Timeout stacking style", {"Stack", "Stack sparingly"},
s.timeoutStackStyle, [](int index) { return index; },
[](auto args) { return args.index; }, false);
layout.addTitle("Emotes");
layout.addDropdown<float>(