Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flags.similar filter variable #5747

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- Minor: Added a setting to hide the scrollbar thumb (the handle you can drag). Hiding the scrollbar thumb will disable mouse click & drag interactions in the scrollbar. (#5731)
- Minor: Added a setting to hide the scrollbar highlights. (#5732)
- Minor: The window layout is now backed up like the other settings. (#5647)
- Minor: Added `flags.similar` filter variable, allowing you to filter messages filtered by the R9K feature. (#5747)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/filters/lang/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const QMap<QString, Type> MESSAGE_TYPING_CONTEXT{
{"flags.restricted", Type::Bool},
{"flags.monitored", Type::Bool},
{"flags.shared", Type::Bool},
{"flags.similar", Type::Bool},
{"message.content", Type::String},
{"message.length", Type::Int},
{"reward.title", Type::String},
Expand Down Expand Up @@ -144,6 +145,7 @@ ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel)
{"flags.restricted", m->flags.has(MessageFlag::RestrictedMessage)},
{"flags.monitored", m->flags.has(MessageFlag::MonitoredMessage)},
{"flags.shared", m->flags.has(MessageFlag::SharedMessage)},
{"flags.similar", m->flags.has(MessageFlag::Similar)},

{"message.content", m->messageText},
{"message.length", m->messageText.length()},
Expand Down
1 change: 1 addition & 0 deletions src/controllers/filters/lang/Tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const QMap<QString, QString> VALID_IDENTIFIERS_MAP{
{"flags.restricted", "restricted message?"},
{"flags.monitored", "monitored message?"},
{"flags.shared", "shared message?"},
{"flags.similar", "r9k filtered message?"},
{"message.content", "message text"},
{"message.length", "message length"},
{"reward.title", "point reward title"},
Expand Down
19 changes: 12 additions & 7 deletions src/widgets/settingspages/GeneralPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,13 +945,14 @@ void GeneralPage::initLayout(GeneralPageView &layout)
toggleLocalr9kShortcut = toggleLocalr9kSeq.toString(
QKeySequence::SequenceFormat::NativeText);
}
layout.addDescription("Hide similar messages. Toggle hidden "
"messages by pressing " +
toggleLocalr9kShortcut + ".");
layout.addCheckbox("Hide similar messages", s.similarityEnabled);
layout.addDescription(
"Hide similar messages to those previously seen. Toggle hidden "
"messages by pressing " +
toggleLocalr9kShortcut + ".");
layout.addCheckbox("Enable similarity checks", s.similarityEnabled);
//layout.addCheckbox("Gray out matches", s.colorSimilarDisabled);
layout.addCheckbox(
"By the same user", s.hideSimilarBySameUser, false,
"Only if by the same user", s.hideSimilarBySameUser, false,
"When checked, messages that are very similar to each other can still "
"be shown as long as they're sent by different users.");
layout.addCheckbox("Hide my own messages", s.hideSimilarMyself);
Expand All @@ -968,7 +969,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
return QString::number(val);
},
[](auto args) {
return fuzzyToFloat(args.value, 0.9f);
return fuzzyToFloat(args.value, 0.9F);
},
true,
"A value of 0.9 means the messages need to be 90% similar to be marked "
Expand All @@ -993,7 +994,11 @@ void GeneralPage::initLayout(GeneralPageView &layout)
},
[](auto args) {
return fuzzyToInt(args.value, 3);
});
},
true,
"How many messages in the history should be compared to a new one to "
"establish its similarity rating. Messages in the history will be "
"compared to only if they are new enough.");

layout.addSubtitle("Visible badges");
layout.addCheckbox("Authority", s.showBadgesGlobalAuthority, false,
Expand Down
Loading